pre-allocated arrays

JavaScript performance comparison

Revision 23 of this test case created by satchmorun

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
empty literal
var arr = [];
var i;

for (i = 0; i < 10000; i++) {
    arr[i] = i;
}

arr=[];
for (i = 0; i < 10000; i++) {
    arr[i] = 2 * i;
}

arr=[];
for (i = 0; i < 10000; i++) {
    arr[i] = 2 * i;
}
pending…
pre-allocated array
var arr = new Array(10000);
var i;
for (i = 0; i < 10000; i++) {
    arr[i] = i;
}

for (i = 0; i < 10000; i++) {
    arr[i] = 2 * i;
}

for (i = 0; i < 10000; i++) {
    arr[i] = 2 * i;
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment