while-vs-for (v26)

Revision 26 of this benchmark created on


Setup

var arr = [1,2,3,4,5,5,6,7],
         foo = 0,
         i = 1000;
    
    while (--i) {
     arr.push(0,2,3,4,5,6,7,8);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
while
var i = -1,
    l = arr.length;

while (i < l) {
   i++; 
   foo++;
}
ready
for
var i = 0,
    l = arr.length;

for (; i < l; i++) {
   foo++;
}
ready
for in
var i = 0;

for (i in arr) {
   foo++;
}
ready

Revisions

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