Push vs length (v12)

Revision 12 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
length
var b = [];
for (var i = 0; i < 100000; i++) {
  b[b.length] = i;
};
ready
push
var a = [];
for (var i = 0; i < 100000; i++) {
  a.push(i);
};
ready
concat
var a = [];
for (var i = 0; i < 100000; i++) {
  a.concat([i]);
};
ready
cached length
var a = [];
for (var i = 0, len = a.length; i < 100000; i++, len++) {
  a[len] = i;
};
ready

Revisions

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