MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/fs/bench-glob.js:24–59  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

22const bench = common.createBenchmark(main, configs);
23
24async function main(config) {
25 const fullPath = path.resolve(benchmarkDirectory, config.dir);
26 const { pattern, recursive, mode } = config;
27 const options = { cwd: fullPath, recursive };
28 const callback = (resolve, reject) => {
29 glob(pattern, options, (err, matches) => {
30 if (err) {
31 reject(err);
32 } else {
33 resolve(matches);
34 }
35 });
36 };
37
38 let noDead;
39 bench.start();
40
41 for (let i = 0; i < config.n; i++) {
42 switch (mode) {
43 case 'sync':
44 noDead = globSync(pattern, options);
45 break;
46 case 'promise':
47 noDead = await globAsync(pattern, options);
48 break;
49 case 'callback':
50 noDead = await new Promise(callback);
51 break;
52 default:
53 throw new Error(`Unknown mode: ${mode}`);
54 }
55 }
56
57 bench.end(config.n);
58 assert.ok(noDead);
59}

Callers

nothing calls this directly

Calls 5

globSyncFunction · 0.85
resolveMethod · 0.45
startMethod · 0.45
endMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected