forloop vs reverse while loop and array reverse (v4)

Revision 4 of this benchmark created on


Description

I know that reverse while looping in javascript is faster than for looping, but if order is to be maintained, would rev-while looping then reversing the array be faster or would the traditional for loop out perform this combo? (EDIT: removing call to console)

Setup

var temp;
  var times;

  Benchmark.prototype.setup = function() {
    temp = [];
    times = 10000;
  };

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
for (var i = 0; i < times; i++) {
  temp.push(i + 1);
}
ready
while loop with reverse for order
var i = times;
while (i--) {
  temp.push(i + 1);
}
 
ready
reversed for loop
for (var i = times; i > 0; i--) {
  temp.push(i);
}
ready

Revisions

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