Array direct assignment vs push (v145)

Revision 145 of this benchmark created by Sergei Kasoverskij on


Setup

var array = [];

Test runner

Ready to run.

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

Revisions

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