array vs object member access

JavaScript performance comparison

Revision 7 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = [1,2,3,4,5],
        b = {a:1,b:2,c:3,d:4};
        c = [0,0,0];
    a.INDEX = 90123123; // <- this
    INDEX = 1203809123;
   
};
</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
c[0] = a[0];
c[1] = a[1];
c[2] = a[2];
pending…
object
c[0] = b.a;
c[1] = b.b;
c[2] = b.c;
pending…
object2
c[0] = b['a'];
c[1] = b['b'];
c[2] = b['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