Performance of Array vs. Object (v110)

Revision 110 of this benchmark created on


Preparation HTML

<script>
var arr = [],
    obj = {},
    i,
    len = 9001,
    sum;
for(i = 0; i < len; i += 1) {
    arr.push(i);
    obj[i] = i;
}
</script>

Setup

sum = 0;
  
  function add(x, y) {
  return x + y;
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Array Performance
for (i = 0; i < len; i += 1) {
  sum = add(sum, arr[i]);
}
ready
Object Performance
for (i in obj) {
  sum = add(sum, obj[i]);
}
ready
Object Performance using known length
for (i = 0; i < len; i += 1) {
  sum = add(sum, obj[i]);
}
ready

Revisions

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