array of funcs iteration

Benchmark created on


Setup

const len = 10;

const arr = [...Array(len).keys()];

const arr1 = arr.map(i => () => {});

const arr2 = arr.slice(0, -1).map(i => () => {});
arr2.push(() => {});

const arr3 = [];
for (let i = 0; i< arr.length; i++) {
  arr3[i] = () => {};
}

Test runner

Ready to run.

Testing in
TestOps/sec
map
for (let i = 0; i < arr1.length; i++) {
  r = arr1[i];
}
ready
map + push
for (let i = 0; i < arr2.length; i++) {
  r = arr2[i];
}
ready
for
for (let i = 0; i < arr3.length; i++) {
  r = arr3[i];
}
ready

Revisions

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