array vs object access times

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr = ['foo', true, 'bar', {}, 'baz'],
        obj = {a: 'foo', b: true, c: 'bar', d: {}, e:'baz'};
};
</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
array access
arr[0] + arr[2];
pending…
object access
obj.a + obj.c;
pending…
on the fly array
var arrf = ['foo', true, 'bar', {}, 'baz'];
arrf[0] + arrf[2];
pending…
on the fly object
var objf = {a: 'foo', b: true, c: 'bar', d: {}, e:'baz'};
objf.a + objf.c;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment