Array Performance (v78)

Revision 78 of this benchmark created on


Description

Manual array lookups vs. holey arrays.

Setup

var a1 = [{id: 'a', name: 'name1'}, {id: 'b', name: 'name1'}];

    var o = {};
    o['a'] = {id: 'a', name: 'name1'};
    o['b'] = {id: 'b', name: 'name1'};

Test runner

Ready to run.

Testing in
TestOps/sec
Manual Array Lookup
var id = 'a';
for (var i = 0; i < a1.length; i++) {
  if (a1[i].id == id) result = a1[i];
}
 
ready
Object by Variable Key
var id = 'a';
var result = o[id];
ready
Object by Static Key
var id = 'a';
var result = o.a;
ready

Revisions

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