Loops - increment vs decrement (v17)

Revision 17 of this benchmark created on


Description

Tests the speed gains when decrementing through a loop vs incrementing through a loop.

Preparation HTML

<script>
  var a = [1, 43, 65, 7, 3, 2, 6, 8, 9, 5, 10, 2];
  var temp;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Decrement Loop
for (var i = 1000 * 3; i > 0; i--) {
 temp = Math.sqrt(i);
}
ready
Increment Loop
for (var i = 0; i < 1000 * 3; i++) {
 temp = Math.sqrt(i);
}
ready
Decrement - one condition
for (var i = 10; i--;) {
 temp = a[(10 - i)];
}
ready

Revisions

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