Performance of Array vs. Object (v105)

Revision 105 of this benchmark created on


Setup

var arr = [],
      i,
      obj = {};
  for(i = 0; i < 10000; i += 1) {
      obj[i] = {body:'aaa',};
      arr.push({
          id: i,
          body:'aaa',
      });
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Array Performance
var id = 10000,
    body;
for (var x=0, current; x< id; x++) {
    current = arr[x];
    if (current.id === id) {
        body = current.body;
        break;
    }
}
ready
Object Performance
var body = obj['10000'];
ready
Object Performance using known length
ready
Using Object.keys()
ready

Revisions

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