0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/fs/bench-readdir.js
Anna Henningsen efabc6ae4d benchmark: fix off-by-one error in fs benchmarks
Fix a off-by-one error that made the benchmarks for asynchronous
functions run `n - 1` times instead of `n` times.

PR-URL: https://github.com/nodejs/node/pull/8338
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-09-11 20:52:57 -07:00

24 lines
409 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
const bench = common.createBenchmark(main, {
n: [1e4],
});
function main(conf) {
const n = conf.n >>> 0;
bench.start();
(function r(cntr) {
if (cntr-- <= 0)
return bench.end(n);
fs.readdir(path.resolve(__dirname, '../../lib/'), function() {
r(cntr);
});
}(n));
}