Loops - increment vs decrement (v14)

Revision 14 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, 11];
  var temp;
  var i=0,j=10;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Decrement Loop
for (var i = 10; i > 0; i--) {
 temp = a[i];
}
ready
Increment Loop
for (var i = 0; i < 10; i++) {
 temp = a[i];
}
ready
increment while
while (temp=a[i++]) {}
ready
decrement while
while (temp=a[j--]) {}
ready
Decrement Loop, not 0 terminal
for (var i = 11; i > 1; i--) {
 temp = a[i];
}
ready
while test 2
while(j) {
temp = a[j];
j--;
}
ready

Revisions

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