forward backward loop with DATA

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;

const DATA = {arr1, arr2, result};

Test runner

Ready to run.

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

Revisions

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