n size array with constructor

JavaScript performance comparison

Test case created

Info

Test case 22July

Preparation code

<script>
  Benchmark.prototype.setup = function() {
    window.growFactor = 4;
  };
</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
Constructor Array
var l = window.growFactor;
var arr = new Array(l);
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
Non Constructor
var arr = [],
  l = window.growFactor;
arr.length = l;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
Const *2
var l = 2*window.growFactor;
var arr = new Array(l);
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…
Non Const *2
var arr = [],
  l = 2*window.growFactor;
arr.length = l;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
pending…

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

Compare results of other browsers

0 comments

Add a comment