mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
f466fe5ecc
PR-URL: https://github.com/nodejs/node/pull/46481 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
26 lines
538 B
JavaScript
26 lines
538 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();
|
|
}
|