Array direct assignment vs push (v82)

Revision 82 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
for (direct)
for (i = 0; i < 100; i++) {
  array[i] = i;
}
ready
for (push)
for (i = 0; i < 100; i++) {
  array.push(i);
}
ready
for (length)
for (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.