Array direct assignment vs push (v81)

Revision 81 of this benchmark created by jerp on


Setup

var array = [];
    var j = -1;

Test runner

Ready to run.

Testing in
TestOps/sec
for (direct)
for (var i = 0; i < 100; i++) {
  array[i] = i;
}
ready
for (push)
for (var i = 0; i < 100; i++) {
  array.push(i);
}
ready
for (length)
for (var i = 0; i < 100; i++) {
  array[array.length] = i;
}
ready
while (direct)
while (++j < 100) {
  array[j] = j;
}
ready
while (push)
while (++j < 100) {
  array.push(j);
}
ready

Revisions

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