Array preallocation performance

JavaScript performance comparison

Revision 5 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  window.growFactor = 1000;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
for-loop Fill (1x)
var arr = [],
    l = window.growFactor;
arr.length = l;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (1x; Not initialized))
var arr = [],
    l = window.growFactor;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (65x)
var arr = [],
    l = 65 * window.growFactor;
arr.length = l;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (65x; Not initialized)
var arr = [],
    l = 65 * window.growFactor;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (65x) alt initialized
var l = 65 * window.growFactor, arr = new Array(l)    
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (65x) alt not initialized
var arr = new Array(),
l = 65 * window.growFactor;
  
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
for-loop Fill (1x) alt
var l = window.growFactor,
arr = new Array(l);
    
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
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.

0 Comments