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

Function benchClassic

benchmark/streams/iter-throughput-compression.js:33–54  ·  view source on GitHub ↗
(chunk, datasize, n, totalOps)

Source from the content-addressed store, hash-verified

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