Array iteration direction

Benchmark created on


Setup

const arr1 = new Array(1000).fill(0).map((val,i)=>i);
const arr2 = new Array(1000).fill(0).map((val,i)=>i);

let result = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
normal
result = 0;
for(let i=0, len=arr1.length;i<len;i++){
	result+=arr1[i];
}
ready
reversed
result = 0;
for(let i=arr2.length-1;i>=0;i--){
	result+=arr2[i];
}
ready

Revisions

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