Retarded test

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function has1(parent, key) {        return Object.prototype.hasOwnProperty.call(parent, key);
    }
   
    function has2(parent, a1, a2, a3, a4) {
        var args = [a1, a2, a3, a4],
                obj = parent;
        for (var i=0; i<4; i++) {
                if (typeof args[i] === 'undefined')
                        return true;
               
                if (Object.prototype.hasOwnProperty.call(obj, args[i]))
                        obj = obj[args[i]];
                else
                        return false;
        }
        return true;
    }
   
    function has3(parent, a1, a2, a3, a4) {
            if (typeof a2 === 'undefined') {
    return Object.prototype.hasOwnProperty.call(parent, a1);
    }
        var args = [a1, a2, a3, a4],
                obj = parent;
        for (var i=0; i<4; i++) {
                if (typeof args[i] === 'undefined')
                        return true;
               
                if (Object.prototype.hasOwnProperty.call(obj, args[i]))
                        obj = obj[args[i]];
                else
                        return false;
        }
        return true;
    }
    var obj = {
    test11: 'test',
    test12: 'test',
    test13: 'test',
    test14: 'test',
    test15: 'test',
    test16: 'test',
    test17: 'test',
    test18: 'test',
    test19: 'test',
    test10: 'test',
    test21: 'test',
    test221: 'test',
    test231: 'test',
    test241: 'test',
    test251: 'test',
    test261: 'test',
    test271: 'test',
    test281: 'test',
    test291: 'test',
    test201: 'test',
    test31: 'test',
    test51: 'test',
    test71: 'test',
    test81: 'test',
    test91: 'test',
    test01: 'test',
    testanand1: 'test',
    testanand11: 'test',
    testanand12: 'test',
    testanand13: 'test',
    testanand14: 'test',
    testanand15: 'test',
    testanand16: 'test',
    testanand17: 'test',
    testanand18: 'test',
    testanand19: 'test',
    testanand10: 'test',
    testanand21: 'test',
    testanand221: 'test',
    testanand231: 'test',
    testanand241: 'test',
    testanand251: 'test',
    testanand261: 'test',
    testanand271: 'test',
    testanand281: 'test',
    testanand291: 'test',
    testanand201: 'test',
    testanand31: 'test',
    testanand51: 'test',
    testanand71: 'test',
    testanand81: 'test',
    testanand91: 'test',
    testanand01: 'test',
    testanand1: 'test'
    };
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
simple
has1(obj, 'test91')
pending…
complicated
has2(obj, 'test91')
pending…
retarded
has3(obj, 'test91')
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment