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

Function main

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

Source from the content-addressed store, hash-verified

11});
12
13function main({ n, type }) {
14 tmpdir.refresh();
15 const options = { encoding: 'utf8' };
16 let prefix;
17 let out = true;
18
19 switch (type) {
20 case 'valid-string':
21 prefix = tmpdir.resolve(`${Date.now()}`);
22 break;
23 case 'valid-buffer':
24 prefix = Buffer.from(tmpdir.resolve(`${Date.now()}`));
25 break;
26 case 'invalid':
27 prefix = tmpdir.resolve('non-existent', 'foo', 'bar');
28 break;
29 default:
30 new Error('Invalid type');
31 }
32
33 bench.start();
34 for (let i = 0; i < n; i++) {
35 try {
36 out = fs.mkdtempSync(prefix, options);
37 } catch {
38 // do nothing
39 }
40 }
41 bench.end(n);
42 assert.ok(out);
43}

Callers

nothing calls this directly

Calls 8

nowMethod · 0.80
mkdtempSyncMethod · 0.80
refreshMethod · 0.45
resolveMethod · 0.45
fromMethod · 0.45
startMethod · 0.45
endMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…