pre-allocated arrays

JavaScript performance comparison

Revision 38 of this test case created by Ivan

Preparation code

<script>
var preAllocated = new Array(1000000);
var empty = [];
</script>
<script>
Benchmark.prototype.setup = function() {
    preAllocated = new Array(1000000);
    empty = [];
};
</script>

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