Array magic vs for vs while (v13)

Revision 13 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
disable - broken on ie
var n = 10000;
var a = [];
for (var i = 0; i < n; i++) {
  a.push(i);
}
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.