Compare async iteration on nested & flat arrays (v3)

Revision 3 of this benchmark created on


Setup

function processAsync(item) {
  return new Promise(function(resolve) {
    setTimeout(
      resolve,
      Math.random() * 1000
    );
  });
}

const data = [...Array(1000).keys()]

const nestedArr = [data, data, data];
const flatArr = [...data, ...data, ...data];

Test runner

Ready to run.

Testing in
TestOps/sec
2D array with nested loop
Promise.all(nestedArr.map(arr => {
  return Promise.all(arr.map(processAsync));
})).then(data => {
  console.log(data);
});
ready
flattened array with loop
Promise.all(flatArr.map(processAsync)).then(data => {
	console.log(data);
})
ready

Revisions

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