pre-allocated arrays (v68)

Revision 68 of this benchmark created by Vasya on


Test runner

Ready to run.

Testing in
TestOps/sec
empty literal
var arr = [];
for (var i = 0; i < 1000000; i++) {
    arr.push(i);
}
ready
pre-allocated array
var arr = new Array(1000000);
for (var i = 0; i < 1000000; i++) {
    arr[i] = i;
}
ready
empty literal v2
var arr = [];
for (var i = 0; i < 1000000; i++) {
    arr[arr.length]=i;
}
ready
pre-allocated through length
var arr = [];
arr.length=1000000;
for (var i = 0; i < 1000000; i++) {
    arr[0]=i;
}
ready

Revisions

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