While vs Do While vs For (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
While loop
var i = 10000;
while (i > 0) {
  Math.cos(Math.PI);
  i -= 1;
}
ready
Do-While loop
var i = 10000;
do {
  i -= 1;
  Math.cos(Math.PI);
} while (i > 0);
ready
For loop
var i;
for (i = 10000; i > 0; i -= 1) {
  Math.cos(Math.PI);
}
ready
For loop (incrementing)
var i;
for (i = 0; i < 10000; i += 1) {
  Math.cos(Math.PI);
}
ready

Revisions

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