arraybuild

JavaScript performance comparison

Test case created by kazuho

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const a1 = [], a2 = [], a3 = new Array(1000000);
  for (let i = 0; i < 1000000; i++) {
    a1[i] = i;
    a2.push(i);
    a3[i] = i;
  }
  

};
</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
[]
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a1);
pending…
push
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a2);
pending…
presized
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a3);
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