Remove micro-optimizations that no longer yield any benefits, restructure timers & immediates to be a bit more straightforward. Adjust timers benchmarks to run long enough to offer meaningful data. PR-URL: https://github.com/nodejs/node/pull/17279 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
20 lines
348 B
JavaScript
20 lines
348 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
thousands: [5000],
|
|
});
|
|
|
|
function main(conf) {
|
|
const N = +conf.thousands * 1e3;
|
|
var n = 0;
|
|
bench.start();
|
|
function cb() {
|
|
n++;
|
|
if (n === N)
|
|
bench.end(N / 1e3);
|
|
}
|
|
for (var i = 0; i < N; i++) {
|
|
setTimeout(cb, 1);
|
|
}
|
|
}
|