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

Function benchWebStream

benchmark/streams/iter-file-read.js:66–86  ·  view source on GitHub ↗
(filesize, n, totalOps)

Source from the content-addressed store, hash-verified

64}
65
66function benchWebStream(filesize, n, totalOps) {
67 const fsp = require('fs/promises');
68
69 async function run() {
70 const fh = await fsp.open(filename, 'r');
71 const rs = fh.readableWebStream();
72 const ws = new WritableStream({ write() {} });
73 await rs.pipeTo(ws);
74 await fh.close();
75 }
76
77 (async () => {
78 // Warmup
79 await run();
80
81 bench.start();
82 for (let i = 0; i < n; i++) await run();
83 fs.unlinkSync(filename);
84 bench.end(totalOps);
85 })();
86}
87
88function benchIter(filesize, n, totalOps) {
89 const fsp = require('fs/promises');

Callers 1

mainFunction · 0.70

Calls 5

runFunction · 0.70
requireFunction · 0.50
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…