Array push() vs unshift() vs direct assignment (v24)

Revision 24 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
push
var a =[];
for (var i=0; i<100; i++) {
  a.push({i: i});
}
ready
Direct Assignment
var a = [];
for (var i=0; i<100; i++) {
  a[i] = {i: i};
}
ready
Fixed array
var a = new Array(100);
for (var i=0; i<100; i++) {
  a[i] = {i: i};
}
ready
map
var a = new Array(100).map(function(v, i) {
  return {i: i};
});
ready

Revisions

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