Array Performance

JavaScript performance comparison

Revision 194 of this test case created by

Preparation code

<script>
  Benchmark.prototype.setup = function() {
    var a1=[];
    var o = {};

    var a2 =[];
    var o2 ={};
    for (var i; i<30001; i++){
        a1[i] = {id: i, name: 'name'+i };
        o[i] = {id: i, name: 'name'+i };
        var d = {id: i, name: 'name'+i };
        a2[i] = d;
        o2[i] = d;
    }
  };
</script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Manual Array Lookup
var id = 29938;
var a = 0;
for (var i = 0; i < a1.length; i++) {
  if (a1[i].id === id)
    result = a1[i];
  else
    a += a1[i].id;
}
pending…
Holey Array by Index
var id = 29938;
var result = a1[id];
pending…
Object by Key
var id = '29938';
var result = o[id];
pending…
Shared Object in array
var id = 29938;
var result = a2[id];
pending…
Shared Object in object
var id = '29938';
var result = o2[id];
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.

0 Comments