• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const assert = require('assert');
4
5const bench = common.createBenchmark(main, {
6  n: [5e6],
7});
8
9function main({ n }) {
10
11  let timer = setTimeout(() => {}, 1);
12  for (let i = 0; i < n; i++) {
13    setTimeout(cb, 1);
14  }
15  let next = timer._idlePrev;
16  clearTimeout(timer);
17
18  bench.start();
19
20  for (let j = 0; j < n; j++) {
21    timer = next;
22    next = timer._idlePrev;
23    clearTimeout(timer);
24  }
25
26  bench.end(n);
27}
28
29function cb() {
30  assert.fail('Timer should not call callback');
31}
32