pre-allocated arrays

JavaScript performance comparison

Revision 38 of this test case created by Ivan

Preparation code

var preAllocated = new Array(1000000);
var empty = [];
Benchmark.prototype.setup = function() {
    preAllocated = new Array(1000000);
    empty = [];

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
for (var i = 0; i < 1000000; i++) {
  empty[i] = 1;
pre-allocated array
for (var i = 0; i < 1000000; i++) {
  preAllocated[i] = 1;

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment