arraybuild

Benchmark created by kazuho on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
[]
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a1);
ready
push
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a2);
ready
presized
(function (a) {
  var s;
  for (let i = 0; i < 1000000; i++)
    s += a[i];
  return s;
})(a3);
ready

Revisions

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