While vs For Queue (v7)

Revision 7 of this benchmark created on


Setup

var items = [], total = 0, i = 0, j = 0, length = 100000;
    for(;i<length;i++) {
      items[i] = Math.ceil( Math.random() * 10 );
    }

Test runner

Ready to run.

Testing in
TestOps/sec
For
for(; j<length; j++) {
  total += items[j];
}
ready
While
while(length) {
  total += items.shift();
}
ready
Do
do {
  total += items.shift();
} while(length);
ready

Revisions

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