Performance of Array vs. Object (v155)

Revision 155 of this benchmark created on


Description

After seeing http://jsperf.com/javascript-associative-vs-non-associative-arrays, I thought the test could be improved.

Setup

var arr = [],
        i,
        obj = {};

Test runner

Ready to run.

Testing in
TestOps/sec
Array delete
for (var x=0; x < 10000; ++x) {
    delete arr[x]
}
ready
Object delete
for (var x=0; x < 10000; ++x) {
    delete obj[x]
}
ready
Array undefined
for (var x=0; x < 10000; ++x) {
   arr[x] = undefined
}
ready
Object undefined
for (var x=0; x < 10000; ++x) {
   obj[x] = undefined
}
ready
Array insert
for(i = 0; i < 10000; i += 1) {
    var o = {payload:i};
    arr[i] = o;
}
 
ready
Object insert
for(i = 0; i < 10000; i += 1) {
    var o = {payload:i};
    obj[i] = o;
}
 
ready

Revisions

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