while-vs-for (v20)

Revision 20 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];
    var foo = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
while
var i = arr.length;

while (i--) {
    foo++;
}
ready
for
var i,len = arr.length;
i = len;
for (; i--;) {
   foo++;
}
ready
for 2
var i,len = arr.length;

for (i = len; i--;) {
   foo++;
}
ready
for 3
var i,len = arr.length;
i = len;
for (; --i;) {
   foo++;
}
ready

Revisions

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