aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/async-overhead.mjs
blob: f05b348e6be72918a363a0bcd655d2beec1e313e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

bench("noop", function () {});
bench("async function(){}", async function () {});
bench("await 1", async function () {
  return await 1;
});
bench("await new Promise(resolve => resolve())", async function () {
  await new Promise((resolve) => resolve());
});
bench(
  "Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))",
  async function () {
    return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1)));
  }
);

await run();