Loops - increment vs decrement (v11)

Revision 11 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 aIndex = a.length;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Decrement Loop
for (var i = aIndex; --i >= 0;) {
  
}
ready
Increment Loop
for (var i = 0; i < aIndex; i++) {
  
}
ready
Increment Loop 2
for (var i = 0; ++i <= aIndex;) {
  
}
ready
Decrement 2
for (var i = aIndex; i >= 0;i--) {
  
}
ready

Revisions

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