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

Function main

benchmark/streams/iter-file-read.js:21–43  ·  view source on GitHub ↗
({ api, filesize, n })

Source from the content-addressed store, hash-verified

19});
20
21function main({ api, filesize, n }) {
22 // Create fixture file
23 const chunk = Buffer.alloc(Math.min(filesize, 64 * 1024), 'abcdefghij');
24 const fd = fs.openSync(filename, 'w');
25 let remaining = filesize;
26 while (remaining > 0) {
27 const size = Math.min(remaining, chunk.length);
28 fs.writeSync(fd, chunk, 0, size);
29 remaining -= size;
30 }
31 fs.closeSync(fd);
32
33 const totalOps = (filesize * n) / (1024 * 1024);
34
35 switch (api) {
36 case 'classic':
37 return benchClassic(filesize, n, totalOps);
38 case 'webstream':
39 return benchWebStream(filesize, n, totalOps);
40 case 'iter':
41 return benchIter(filesize, n, totalOps);
42 }
43}
44
45function benchClassic(filesize, n, totalOps) {
46 function run(cb) {

Callers

nothing calls this directly

Calls 8

allocMethod · 0.80
benchClassicFunction · 0.70
benchWebStreamFunction · 0.70
benchIterFunction · 0.70
minMethod · 0.45
openSyncMethod · 0.45
writeSyncMethod · 0.45
closeSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…