diff options
Diffstat (limited to 'benchmark/process/queue-microtask-depth.js')
-rw-r--r-- | benchmark/process/queue-microtask-depth.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/benchmark/process/queue-microtask-depth.js b/benchmark/process/queue-microtask-depth.js new file mode 100644 index 0000000000..407feb1b32 --- /dev/null +++ b/benchmark/process/queue-microtask-depth.js @@ -0,0 +1,17 @@ +'use strict'; +const common = require('../common.js'); +const bench = common.createBenchmark(main, { + n: [12e5] +}); + +function main({ n }) { + let counter = n; + bench.start(); + queueMicrotask(onNextTick); + function onNextTick() { + if (--counter) + queueMicrotask(onNextTick); + else + bench.end(n); + } +} |