Performance of Array vs. Object (v129)

Revision 129 of this benchmark created on


Setup

var arr = [],
      i,
      obj = {};
  for(i = 0; i < 10; i += 1) {
      var o = {payload:i};
      arr.push(o);
      obj[i] = o;
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Array Performance
var x = 0;
while(x<arr.length)++x;
ready
Object Performance
var x = 0;
while(x<arr.length)++x;
ready
Object Performance using known length
var x = 0;
while(x<arr.length)++x;
ready
Using Object.keys()
var x = 0;
while(x < Object.keys(obj).length)++x;
ready
Array Performance known length
var x = 0;
while(x < Object.keys(obj).length)++x;
ready
Array using .foreach
var x = 0;
while(x < Object.keys(obj).length)++x;
ready

Revisions

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