loops

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
3 for..of
const arr1 = new Array(100_000);
const arr2 = new Array(1_000);
const arr3 = new Array(10);

let counter = 0;

for (const x of arr1) {
  for (const y of arr2) {
    for (const z of arr3) {
      ++counter;
    }
  }
}
console.log('   counter', counter);
ready
2 for..of 1 for
const arr1 = new Array(100_000);
const arr2 = new Array(1_000);
const arr3 = new Array(10);

let counter = 0;

for (const x of arr1) {
  for (const y of arr2) {
    for (let z = 0, len3 = arr3.length; z < len3; ++z) {
      ++counter;
    }
  }
}
console.log('   counter', counter);
ready

Revisions

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