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

Function runTest

benchmark/fs/read-stream-throughput.js:69–94  ·  view source on GitHub ↗
(filesize, highWaterMark, encoding, n)

Source from the content-addressed store, hash-verified

67}
68
69function runTest(filesize, highWaterMark, encoding, n) {
70 assert.strictEqual(fs.statSync(filename).size, filesize * n);
71 const rs = fs.createReadStream(filename, {
72 highWaterMark,
73 encoding,
74 });
75
76 rs.on('open', () => {
77 bench.start();
78 });
79
80 let bytes = 0;
81 rs.on('data', (chunk) => {
82 bytes += chunk.length;
83 });
84
85 rs.on('end', () => {
86 try {
87 fs.unlinkSync(filename);
88 } catch {
89 // Continue regardless of error.
90 }
91 // MB/sec
92 bench.end(bytes / (1024 * 1024));
93 });
94}

Callers

nothing calls this directly

Calls 6

statSyncMethod · 0.45
createReadStreamMethod · 0.45
onMethod · 0.45
startMethod · 0.45
unlinkSyncMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected