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

Function benchClassic

benchmark/streams/iter-throughput-transform.js:41–67  ·  view source on GitHub ↗
(chunk, datasize, n, totalOps)

Source from the content-addressed store, hash-verified

39}
40
41function benchClassic(chunk, datasize, n, totalOps) {
42 function run(cb) {
43 let remaining = datasize;
44 const r = new Readable({
45 read() {
46 if (remaining <= 0) { this.push(null); return; }
47 const size = Math.min(remaining, chunk.length);
48 remaining -= size;
49 this.push(size === chunk.length ? chunk : chunk.subarray(0, size));
50 },
51 });
52 const t = new Transform({
53 transform(data, enc, cb) {
54 cb(null, copyBuf(data));
55 },
56 });
57 const w = new Writable({ write(data, enc, cb) { cb(); } });
58 pipeline(r, t, w, cb);
59 }
60
61 let i = 0;
62 bench.start();
63 (function next() {
64 if (i++ >= n) return bench.end(totalOps);
65 run(next);
66 })();
67}
68
69function benchWebStream(chunk, datasize, n, totalOps) {
70 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…