summaryrefslogtreecommitdiff
path: root/benchmark/timers/timers-cancel-unpooled.js
blob: a040fad69e1c6632e9ee0d6890a6c710ab4e2b24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
var common = require('../common.js');
var assert = require('assert');

var bench = common.createBenchmark(main, {
  thousands: [100],
});

function main(conf) {
  var iterations = +conf.thousands * 1e3;

  var timersList = [];
  for (var i = 0; i < iterations; i++) {
    timersList.push(setTimeout(cb, i + 1));
  }

  bench.start();
  for (var j = 0; j < iterations + 1; j++) {
    clearTimeout(timersList[j]);
  }
  bench.end(iterations / 1e3);
}

function cb() {
  assert(false, 'Timer ' + this._idleTimeout + ' should not call callback');
}