array of funcs iteration (v3)

Revision 3 of this 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] = () => {};
}

const arr4 = [];
for (let i = 0; i< arr.length - 1; i++) {
  arr4[i] = () => {};
} 
arr4.push(() => {});

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

Test runner

Ready to run.

Testing in
TestOps/sec
map
iterate(arr1);
ready
map + push
iterate(arr2);
ready
for
iterate(arr3);
ready
for + push
iterate(arr3);
ready

Revisions

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