• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common.js');
4const bench = common.createBenchmark(main, {
5  n: [5e6],
6});
7
8function main({ n }) {
9
10  process.on('exit', () => {
11    bench.end(n);
12  });
13
14  function cb3(n, arg2, arg3) {
15    if (--n) {
16      if (n % 3 === 0)
17        setImmediate(cb3, n, true, null, 5.1, null, true);
18      else if (n % 2 === 0)
19        setImmediate(cb2, n, 5.1, true);
20      else
21        setImmediate(cb1, n);
22    }
23  }
24
25  function cb2(n, arg2) {
26    if (--n) {
27      if (n % 3 === 0)
28        setImmediate(cb3, n, true, null, 5.1, null, true);
29      else if (n % 2 === 0)
30        setImmediate(cb2, n, 5.1, true);
31      else
32        setImmediate(cb1, n);
33    }
34  }
35
36  function cb1(n) {
37    if (--n) {
38      if (n % 3 === 0)
39        setImmediate(cb3, n, true, null, 5.1, null, true);
40      else if (n % 2 === 0)
41        setImmediate(cb2, n, 5.1, true);
42      else
43        setImmediate(cb1, n);
44    }
45  }
46  bench.start();
47  setImmediate(cb1, n);
48}
49