summaryrefslogtreecommitdiff
path: root/benchmark/timers/timers-depth.js
blob: bfc6dd02cf5c65b23795c94c59da2960186b51c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
  n: [1e3],
});

function main({ n }) {
  var i = 0;
  bench.start();
  setTimeout(cb, 1);
  function cb() {
    i++;
    if (i === n)
      bench.end(n);
    else
      setTimeout(cb, 1);
  }
}