Array Iteration (v14)

Revision 14 of this benchmark created on


Description

Compare iterating forward or backwards of an array

Setup

var arr = [];
    for (var i = 0; i < 10000; ++i) {
      arr.push(1);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
forwards
var v = Math.random();
for (var i = 0; i < arr.length; ++i) {
  v *= 1.33;
}
return v;
ready
backwards
var v = Math.random();
for (var i = arr.length - 1; i >= 0; --i) {
  v *= 1.33;
}
return v;
ready
Hard Coded Forward
var v = Math.random();
for (var i = 0; i < 10000; ++i) {
  v *= 1.33;
}
return v;
ready
Cached Forward Iteration
var v = Math.random();
for(var i=0, c=arr.length; i<c; i++){
  v *= 1.33;

}
return v;
ready
cached forward 2
var v = Math.random();
var c = arr.length
for(var i=0; i<c; i++){
  v *= 1.33;

}
return v;
ready

Revisions

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