blob: 3e262f820a3e0865f06a8abd5f0295e4f6a01283 (
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
27
28
29
30
31
32
|
'use strict';
const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
millions: [5],
});
function main({ millions }) {
const iterations = millions * 1e6;
var timer = setTimeout(() => {}, 1);
for (var i = 0; i < iterations; i++) {
setTimeout(cb, 1);
}
var next = timer._idlePrev;
clearTimeout(timer);
bench.start();
for (var j = 0; j < iterations; j++) {
timer = next;
next = timer._idlePrev;
clearTimeout(timer);
}
bench.end(iterations / 1e6);
}
function cb() {
assert.fail('Timer should not call callback');
}
|