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

Function benchThroughput

benchmark/streams/compose.js:63–99  ·  view source on GitHub ↗
(n, numberOfPassThroughs, chunks)

Source from the content-addressed store, hash-verified

61}
62
63function benchThroughput(n, numberOfPassThroughs, chunks) {
64 const chunk = Buffer.alloc(1024);
65
66 let i = 0;
67 bench.start();
68
69 function run() {
70 if (i++ === n) {
71 bench.end(n * chunks);
72 return;
73 }
74
75 const passThroughs = [];
76 for (let i = 0; i < numberOfPassThroughs; i++) {
77 passThroughs.push(new PassThrough());
78 }
79
80 let remaining = chunks;
81 const composed = compose(...passThroughs);
82 composed.on('data', () => {});
83 composed.on('end', run);
84
85 write();
86
87 function write() {
88 while (remaining-- > 0) {
89 if (!composed.write(chunk)) {
90 composed.once('drain', write);
91 return;
92 }
93 }
94 composed.end();
95 }
96 }
97
98 run();
99}

Callers 1

mainFunction · 0.85

Calls 3

allocMethod · 0.80
runFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…