diff options
Diffstat (limited to 'bench/snippets/async-overhead.mjs')
-rw-r--r-- | bench/snippets/async-overhead.mjs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs index f05b348e6..bec278b56 100644 --- a/bench/snippets/async-overhead.mjs +++ b/bench/snippets/async-overhead.mjs @@ -5,6 +5,19 @@ bench("async function(){}", async function () {}); bench("await 1", async function () { return await 1; }); + +function callnextTick(resolve) { + process.nextTick(resolve); +} + +function awaitNextTick() { + return new Promise(callnextTick); +} + +bench("promise.nextTick", async function () { + return awaitNextTick(); +}); + bench("await new Promise(resolve => resolve())", async function () { await new Promise((resolve) => resolve()); }); @@ -12,7 +25,7 @@ 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(); |