node/benchmark/process/next-tick-exec.js
Anatoli Papirovski 34bd9f318a
benchmark: track exec time in next-tick-exec
The next-tick-exec benchmarks were meant to track nextTick execution
time but due to an error, they actually track addition and execution.

PR-URL: https://github.com/nodejs/node/pull/20462
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-06 07:29:47 +02:00

19 lines
304 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [5e6]
});
function main({ n }) {
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}
for (var i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}
bench.start();
}