loop

Benchmark created on


Setup

const arr = []
const length = 1000;
for(let i = 0; i < length; i++) {
	arr[i] = new Array(length).fill(0);
}

Test runner

Ready to run.

Testing in
TestOps/sec
row
let sum = 0;
for(let i = 0; i < length; i++) {
	for(let j = 0; j < length; j++) {
		sum += arr[i][j];
	}
}

ready
col
let sum = 0;
for(let i = 0; i < length; i++) {
	for(let j = 0; j < length; j++) {
		sum += arr[j][i];
	}
}
ready

Revisions

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