Array direct assignment vs push (v17)

Revision 17 of this benchmark created on


Setup

var array = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Direct assignment
for(var i = 0; i < 100; i++)
{
  array[i] = i;
}
ready
Push
for(var i = 0; i < 100; i++)
{
  array.push(i);
}
ready
Direct assignment (calculated)
for(var i = 0; i < 100; i++)
{
  array[array.length - 1] = i;
}
ready

Revisions

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