node/benchmark/process/next-tick-exec-args.js
Alex Ramirez d0ed431041
benchmark: swap var for let in benchmarks
In benchmark directory this changes for loops
using var to let when it applies for consistency

PR-URL: https://github.com/nodejs/node/pull/28958
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-02-13 21:38:00 +01:00

26 lines
537 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [4e6]
});
function main({ n }) {
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}
for (let i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test');
else if (i % 3 === 0)
process.nextTick(onNextTick, i, true, 10);
else if (i % 2 === 0)
process.nextTick(onNextTick, i, 20);
else
process.nextTick(onNextTick, i);
}
bench.start();
}