diff options
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/process/queue-microtask-breadth.js | 21 | ||||
-rw-r--r-- | benchmark/process/queue-microtask-depth.js | 17 |
2 files changed, 38 insertions, 0 deletions
diff --git a/benchmark/process/queue-microtask-breadth.js b/benchmark/process/queue-microtask-breadth.js new file mode 100644 index 0000000000..8bb33f6fde --- /dev/null +++ b/benchmark/process/queue-microtask-breadth.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common.js'); +const bench = common.createBenchmark(main, { + n: [4e5] +}); + +function main({ n }) { + var j = 0; + + function cb() { + j++; + if (j === n) + bench.end(n); + } + + bench.start(); + for (var i = 0; i < n; i++) { + queueMicrotask(cb); + } +} 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); + } +} |