• 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 cb1(arg1) {}
15
16  function cb2(arg1, arg2) {}
17
18  function cb3(arg1, arg2, arg3) {}
19
20  bench.start();
21  for (let i = 0; i < n; i++) {
22    if (i % 3 === 0)
23      setImmediate(cb3, 512, true, null, 512, true, null);
24    else if (i % 2 === 0)
25      setImmediate(cb2, false, 5.1, 512);
26    else
27      setImmediate(cb1, 0);
28  }
29}
30