The loops

Benchmark created by Barbara Cassani on


Description

Is the "reverse while" really faster than a normal for loop? And if yes, how much?

Setup

var iterations = 100,
        a = 0,
        i = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
The "reverse while"
while (iterations > 0) {
  a = a + 1;
  a = a - 1;
  iterations--;
}
ready
The "normal for"
for (i = 0; i < iterations; i++) {
  a = a + 1;
  a = a - 1;
}
ready

Revisions

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

  • Revision 1: published by Barbara Cassani on