Pre-allocation of array

Benchmark created by Adam Fullen on


Description

Tests performance in pre-allocating array memory

Test runner

Ready to run.

Testing in
TestOps/sec
Pre-allocated array
var max = 10000;
var a = new Array(max);
var aLength = 0;
a.length = aLength;
a[aLength] = aLength;

for(var x = 0; x < max; x++){
a[aLength++] = aLength;
}


 
ready
Pushed Array
var max = 10000;
var a = new Array();

for(var x = 0; x < max; x++){
a.push(x);
}
ready

Revisions

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

  • Revision 1: published by Adam Fullen on