Array Iteration (Nested) (v24)

Revision 24 of this benchmark created on


Description

Compare iterating forward or backwards of an array with nested loops

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
forwards
for (var i = 0; i < arr.length; ++i) {
    for (var j = 0; j < arr.length; ++j) {
    }
}
ready
backwards
for (var i = arr.length; i > 0; --i) {
  for (var j = arr.length; j > 0; --j) {
  }
}
ready
Hard Coded Forward
for (var i = 0; i < 10000; ++i) {
  for (var j = 0; j < 10000; ++j) {
  }
}
ready
Cached Forward Iteration
for(var i=0, c=arr.length; i<c; i++){
  for(var j=0, d=arr.length; j<d; j++){
  }
}
ready

Revisions

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