MCPcopy Create free account
hub / github.com/nodejs/node / benchClassic

Function benchClassic

benchmark/streams/iter-throughput-pipeto.js:36–57  ·  view source on GitHub ↗
(chunk, datasize, n, totalOps)

Source from the content-addressed store, hash-verified

34}
35
36function benchClassic(chunk, datasize, n, totalOps) {
37 function run(cb) {
38 let remaining = datasize;
39 const r = new Readable({
40 read() {
41 if (remaining <= 0) { this.push(null); return; }
42 const size = Math.min(remaining, chunk.length);
43 remaining -= size;
44 this.push(size === chunk.length ? chunk : chunk.subarray(0, size));
45 },
46 });
47 const w = new Writable({ write(data, enc, cb) { cb(); } });
48 pipeline(r, w, cb);
49 }
50
51 let i = 0;
52 bench.start();
53 (function next() {
54 if (i++ >= n) return bench.end(totalOps);
55 run(next);
56 })();
57}
58
59function benchWebStream(chunk, datasize, n, totalOps) {
60 async function run() {

Callers 1

mainFunction · 0.70

Calls 3

runFunction · 0.70
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected