pre-allocated arrays (v59)

Revision 59 of this benchmark created by Barfoo on


Test runner

Ready to run.

Testing in
TestOps/sec
empty literal
var arr = [];
for (var i = 0; i < 5; i++) {
    arr[i] = i;
}
ready
pre-allocated array overflows
var arr = new Array(3);
for (var i = 0; i < 5; i++) {
    arr[i] = i;
}
ready
pre-allocated array
var arr = new Array(5);
for (var i = 0; i < 5; i++) {
    arr[i] = i;
}
ready
large literal
var arr = [];
for (var i = 0; i < 500; i++) {
    arr[i] = i;
}
ready
large pre-allocated overflows
var arr = new Array(300);
for (var i = 0; i < 500; i++) {
    arr[i] = i;
}
ready
large pre-allocated
var arr = new Array(500);
for (var i = 0; i < 500; i++) {
    arr[i] = i;
}
ready
literal push
var arr = [];
for (var i = 0; i < 5; i++) {
    arr.push(i);
}
ready
pre-allocated push
var arr = new Array(5);
for (var i = 0; i < 5; i++) {
    arr.push(i);
}
ready

Revisions

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