1'use strict';
2const common = require('../common.js');
3const bench = common.createBenchmark(main, {
4  n: [1e4, 2e4, 4e4],
5  loop: [1e2, 2e2],
6});
7
8function main({ n, loop }) {
9  bench.start();
10  run();
11  function run() {
12    let j = 0;
13
14    function cb() {
15      j++;
16      if (j === n) {
17        loop--;
18        if (loop === 0) {
19          bench.end(n);
20        } else {
21          run();
22        }
23      }
24    }
25
26    for (let i = 0; i < n; i++) {
27      process.nextTick(cb);
28    }
29  }
30}
31