Array direct assignment vs push (big array) (v31)

Revision 31 of this benchmark created on


Setup

var array = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Direct assignment
for(var i = 0; i < 100000; i++)
{
  array[i] = "test";
}
ready
Push
for(var i = 0; i < 100000; i++)
{
  array.push("test");
}
ready
Direct assignment with pre-allocate
// bad luck, the array is not big enough (when we only know the minimum size)
array.length = 90000;
for(var i = 0; i < 100000; i++)
{
  array[i] = "test";
}
ready

Revisions

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