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

Function main

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

Source from the content-addressed store, hash-verified

11});
12
13function main({ n, type }) {
14 let files;
15
16 switch (type) {
17 case 'existing':
18 files = [];
19
20 // Populate tmpdir with mock files
21 for (let i = 0; i < n; i++) {
22 const path = tmpdir.resolve(`unlinksync-bench-file-${i}`);
23 fs.writeFileSync(path, 'bench');
24 files.push(path);
25 }
26 break;
27 case 'non-existing':
28 files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
29 break;
30 default:
31 new Error('Invalid type');
32 }
33
34 bench.start();
35 for (let i = 0; i < n; i++) {
36 try {
37 fs.unlinkSync(files[i]);
38 } catch {
39 // do nothing
40 }
41 }
42 bench.end(n);
43}

Callers

nothing calls this directly

Calls 8

fillMethod · 0.80
nowMethod · 0.80
resolveMethod · 0.45
writeFileSyncMethod · 0.45
pushMethod · 0.45
startMethod · 0.45
unlinkSyncMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…