aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/async-overhead.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'bench/snippets/async-overhead.mjs')
-rw-r--r--bench/snippets/async-overhead.mjs18
1 files changed, 18 insertions, 0 deletions
diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs
new file mode 100644
index 000000000..f05b348e6
--- /dev/null
+++ b/bench/snippets/async-overhead.mjs
@@ -0,0 +1,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();