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

Function benchIter

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

Source from the content-addressed store, hash-verified

90}
91
92function benchIter(chunk, datasize, n, totalOps) {
93 const { pipeTo } = require('stream/iter');
94
95 async function run() {
96 let remaining = datasize;
97 async function* source() {
98 while (remaining > 0) {
99 const size = Math.min(remaining, chunk.length);
100 remaining -= size;
101 yield [size === chunk.length ? chunk : chunk.subarray(0, size)];
102 }
103 }
104 // Drain to no-op sink, matching classic/webstream behavior
105 await pipeTo(source(), { write() {}, writeSync() { return true; } });
106 }
107
108 (async () => {
109 bench.start();
110 for (let i = 0; i < n; i++) await run();
111 bench.end(totalOps);
112 })();
113}
114
115function benchIterSync(chunk, datasize, n, totalOps) {
116 const { pipeToSync } = require('stream/iter');

Callers 1

mainFunction · 0.70

Calls 4

runFunction · 0.70
requireFunction · 0.50
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected