mirror of
https://github.com/nodejs/node.git
synced 2024-11-22 07:37:56 +01:00
bae03c4e30
PR-URL: https://github.com/nodejs/node/pull/44499 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
31 lines
487 B
JavaScript
31 lines
487 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e4, 2e4, 4e4],
|
|
loop: [1e2, 2e2],
|
|
});
|
|
|
|
function main({ n, loop }) {
|
|
bench.start();
|
|
run();
|
|
function run() {
|
|
let j = 0;
|
|
|
|
function cb() {
|
|
j++;
|
|
if (j === n) {
|
|
loop--;
|
|
if (loop === 0) {
|
|
bench.end(n);
|
|
} else {
|
|
run();
|
|
}
|
|
}
|
|
}
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
process.nextTick(cb);
|
|
}
|
|
}
|
|
}
|