node/benchmark/process/next-tick-depth.js
Anatoli Papirovski 289e4cef3f
benchmark: fix next-tick-depth
A recent change made these benchmarks fail by always finishing
with 0 iterations. Restore a counter variable.

PR-URL: https://github.com/nodejs/node/pull/20461
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2018-05-08 14:22:25 -07:00

19 lines
357 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [12e6]
});
process.maxTickDepth = Infinity;
function main({ n }) {
let counter = n;
bench.start();
process.nextTick(onNextTick);
function onNextTick() {
if (--counter)
process.nextTick(onNextTick);
else
bench.end(n);
}
}