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

Function main

benchmark/fs/bench-ftruncateSync.js:16–40  ·  view source on GitHub ↗
({ n, type })

Source from the content-addressed store, hash-verified

14});
15
16function main({ n, type }) {
17 let fd;
18
19 switch (type) {
20 case 'invalid':
21 fd = 1 << 30;
22 break;
23 case 'valid':
24 fd = fs.openSync(path, 'r+');
25 break;
26 default:
27 throw new Error('Invalid type');
28 }
29
30 bench.start();
31 for (let i = 0; i < n; i++) {
32 try {
33 fs.ftruncateSync(fd, 4);
34 } catch {
35 // do nothing
36 }
37 }
38 bench.end(n);
39 if (type === 'valid') fs.closeSync(fd);
40}

Callers

nothing calls this directly

Calls 5

ftruncateSyncMethod · 0.80
openSyncMethod · 0.45
startMethod · 0.45
endMethod · 0.45
closeSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…