Array magic vs for vs while (v14)

Revision 14 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Map
var n = 2000;
var a = Array.apply(null, {
  length: n
}).map(Number.call, Number);
ready
For push
var n = 10000;
var a = [];
for (var i = 0; i < n; i++) {
  a.push(i);
}
ready
While set backwards
var n = 10000;
var b = n;
var a = [];
while (b--) a[b] = b;
ready
While set forwards
var n = 10000;
var b = 0;
var a = [];
while (b++ < n) a[b] = b;
ready
For set
var n = 10000;
var a = [];
for (var i = 0; i < n; i++) {
  a[i] = i;
}
ready
While push
var n = 10000;
var b = 0;
var a = [];
while (b++ < n) a.push(b);
ready

Revisions

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