Loops - increment vs decrement (v16)

Revision 16 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
var i = 10;
for (; i > 0; i--) {
 temp = a[i];
}
ready
Increment Loop
var i = 0;
for (; i < 10; i++) {
 temp = a[i];
}
ready
Decrement - one condition
var i = 10;
for (; i--;) {
 temp = a[i];
}
ready
pre m 1
var i = 10;
for (; i > 0; --i) {
 temp = a[i];
}
ready
pree a 1
var i = 0;
for (; i < 10; ++i) {
 temp = a[i];
}
ready
pre m 2
var i = 10;
for (; --i;) {
 temp = a[i];
}
ready

Revisions

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