mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
ca51b9471c
PR-URL: https://github.com/nodejs/node/pull/24125
Refs: 0483e9a9ab
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
25 lines
563 B
JavaScript
25 lines
563 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [10],
|
|
dir: [ 'lib', 'test/parallel'],
|
|
withFileTypes: ['true', 'false']
|
|
});
|
|
|
|
function main({ n, dir, withFileTypes }) {
|
|
withFileTypes = withFileTypes === 'true';
|
|
const fullPath = path.resolve(__dirname, '../../', dir);
|
|
bench.start();
|
|
(function r(cntr) {
|
|
if (cntr-- <= 0)
|
|
return bench.end(n);
|
|
fs.readdir(fullPath, { withFileTypes }, function() {
|
|
r(cntr);
|
|
});
|
|
}(n));
|
|
}
|