Using map with and without async await

Benchmark created on


Setup

const sleep = async (num, time = 1500) => new Promise(resolve => {
    setTimeout(() => {
        resolve(num);
    }, num * time);
});

Test runner

Ready to run.

Testing in
TestOps/sec
Using Promise.all for map
const arr = [1, 2, 3, 4, 5];

await Promise.all(
  arr.map(async item => sleep(item))
);
ready
Awaiting inside map
const arr = [1, 2, 3, 4, 5];

arr.map(async item => await sleep(item))
ready

Revisions

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