while-vs-for (v33)

Revision 33 of this benchmark created on


Setup

var arr = [0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9];

Test runner

Ready to run.

Testing in
TestOps/sec
while
var l = arr.length,
    i = 0,
    a = [0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9],
    b = [];

while (i < l) {
  b[i] = a[i];
  i+=1;
}
ready
for
var l = arr.length,
    a = [0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9],
    b = [];

b.push.apply(b,a)
ready

Revisions

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