mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
090add7864
Refs: https://github.com/nodejs/node/pull/51912 PR-URL: https://github.com/nodejs/node/pull/54644 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
38 lines
874 B
JavaScript
38 lines
874 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const assert = require('node:assert');
|
|
|
|
const benchmarkDirectory = path.resolve(__dirname, '..', '..');
|
|
|
|
const configs = {
|
|
n: [1e3],
|
|
dir: ['lib'],
|
|
pattern: ['**/*', '*.js', '**/**.js'],
|
|
mode: ['async', 'sync'],
|
|
recursive: ['true', 'false'],
|
|
};
|
|
|
|
const bench = common.createBenchmark(main, configs);
|
|
|
|
async function main(config) {
|
|
const fullPath = path.resolve(benchmarkDirectory, config.dir);
|
|
const { pattern, recursive, mode } = config;
|
|
|
|
let noDead;
|
|
bench.start();
|
|
|
|
for (let i = 0; i < config.n; i++) {
|
|
if (mode === 'async') {
|
|
noDead = await fs.promises.glob(pattern, { cwd: fullPath, recursive });
|
|
} else {
|
|
noDead = fs.globSync(pattern, { cwd: fullPath, recursive });
|
|
}
|
|
}
|
|
|
|
bench.end(config.n);
|
|
assert.ok(noDead);
|
|
}
|