Array Versus Object (v9)

Revision 9 of this benchmark created by mordof on


Test runner

Ready to run.

Testing in
TestOps/sec
Array
var arr = [];
arr.push('test');
arr.push({foo: 'bar'});
arr[0];
arr[1];
ready
Object
var obj = {};
obj['key'] = 'test';
obj['val'] = {foo: 'bar'};
obj['key'];
obj['val'];
ready
Array (w/o push)
var arr = [];
arr[0] = 'test';
arr[1] = {foo: 'bar'};
arr[0];
arr[1];
ready
Object with num keys
var obj = {};
obj[0] = 'test';
obj[1] = {foo: 'bar'};
obj[0];
obj[1];
ready
array with non-sequential keys
var testarr = [];
testarr[0] = 'test';
testarr[250000] = {foo: 'bar'};
testarr[0];
testarr[250000];
ready
array with non-sequential keys reverse index
var testarr = {};
testarr[250000] = {foo: 'bar'};
testarr[10] = 'test';
testarr[10];
testarr[250000];
ready
obj with int->str keys
var testarr = {};
testarr[0+''] = 'test';
testarr[250000+''] = {foo: 'bar'};
testarr[0+''];
testarr[250000+''];
ready

Revisions

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

  • Revision 9: published by mordof on