Array Performance (v47)

Revision 47 of this benchmark created on


Setup

var a1 = [];
    var o1 = {};
    for (var i = 0; i < 1000; i++) {
	      var id = Math.floor(Math.random() * 100000) + 1;

if(i===500){
a1.push("TEST");
	      o1.TEST = "TEST";
}

	      a1.push(id);
	      o1.id = id;

    }

Test runner

Ready to run.

Testing in
TestOps/sec
Manual Array Lookup
var id = "TEST";
for (var i = 0; i < a1.length; i++) {
  if (a1[id] !== undefined) break;
}
ready
indexOf
a1.indexOf("TEST");
ready
Object by Key
if( o1["TEST"] !== undefined){

}
ready

Revisions

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