MCPcopy Create free account
hub / github.com/nodejs/node / main

Function main

benchmark/fs/bench-opendirSync.js:17–43  ·  view source on GitHub ↗
({ n, type })

Source from the content-addressed store, hash-verified

15});
16
17function main({ n, type }) {
18 let files;
19
20 switch (type) {
21 case 'existing':
22 files = testFiles;
23 break;
24 case 'non-existing':
25 files = [tmpdir.resolve(`.non-existing-file-${Date.now()}`)];
26 break;
27 default:
28 new Error('Invalid type');
29 }
30
31 bench.start();
32 for (let i = 0; i < n; i++) {
33 for (let j = 0; j < files.length; j++) {
34 try {
35 const dir = fs.opendirSync(files[j]);
36 dir.closeSync();
37 } catch {
38 // do nothing
39 }
40 }
41 }
42 bench.end(n);
43}

Callers

nothing calls this directly

Calls 6

nowMethod · 0.80
opendirSyncMethod · 0.80
resolveMethod · 0.45
startMethod · 0.45
closeSyncMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected