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

Function main

benchmark/fs/bench-filehandle-pull-vs-webstream.js:30–49  ·  view source on GitHub ↗
({ api, compression, filesize, n })

Source from the content-addressed store, hash-verified

28});
29
30function main({ api, compression, filesize, n }) {
31 // Create the fixture file with repeating lowercase ASCII
32 const chunk = Buffer.alloc(Math.min(filesize, 64 * 1024), 'abcdefghij');
33 const fd = fs.openSync(filename, 'w');
34 let remaining = filesize;
35 while (remaining > 0) {
36 const toWrite = Math.min(remaining, chunk.length);
37 fs.writeSync(fd, chunk, 0, toWrite);
38 remaining -= toWrite;
39 }
40 fs.closeSync(fd);
41
42 if (api === 'classic') {
43 benchClassic(n, filesize).then(() => cleanup());
44 } else if (api === 'webstream') {
45 benchWebStream(n, filesize).then(() => cleanup());
46 } else {
47 benchPull(n, filesize, compression).then(() => cleanup());
48 }
49}
50
51function cleanup() {
52 try { fs.unlinkSync(filename); } catch { /* ignore */ }

Callers

nothing calls this directly

Calls 10

benchPullFunction · 0.85
allocMethod · 0.80
benchClassicFunction · 0.70
cleanupFunction · 0.70
benchWebStreamFunction · 0.70
minMethod · 0.45
openSyncMethod · 0.45
writeSyncMethod · 0.45
closeSyncMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…