0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/process/next-tick-depth.js
Brian White 34961c7b5f
process: improve nextTick performance
PR-URL: https://github.com/nodejs/node/pull/25461
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-08-27 22:14:15 -04:00

18 lines
322 B
JavaScript

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