0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 12:10:08 +01:00
nodejs/benchmark/timers/timers-breadth.js
Daniele Belardi de877c5781
benchmark: use let instead of var in timers
PR-URL: https://github.com/nodejs/node/pull/31794
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-03-30 10:16:16 +02:00

20 lines
299 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [5e6],
});
function main({ n }) {
let j = 0;
bench.start();
function cb() {
j++;
if (j === n)
bench.end(n);
}
for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
}