Push vs length (v22)

Revision 22 of this benchmark created by ThoAppelsin on


Test runner

Ready to run.

Testing in
TestOps/sec
length
var myArray = [];
for (i = 0; i < 100000; i++) {
  myArray[myArray.length] = i;
}
ready
push
var myArray = [];
for (i = 0; i < 100000; i++) {
  myArray.push(i);
}
ready
pre-allocating the array
var myArray = new Array(100000);
for (i = 0; i < 100000; i++) {
  myArray[i] = i;
}
ready

Revisions

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