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

Function benchClassic

benchmark/streams/iter-throughput-identity.js:34–62  ·  view source on GitHub ↗
(chunk, datasize, n, totalOps)

Source from the content-addressed store, hash-verified

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