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

Function benchIter

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

Source from the content-addressed store, hash-verified

80}
81
82function benchIter(chunk, datasize, n, totalOps) {
83 const { pipeTo } = require('stream/iter');
84
85 async function run() {
86 let remaining = datasize;
87 async function* source() {
88 while (remaining > 0) {
89 const size = Math.min(remaining, chunk.length);
90 remaining -= size;
91 yield [size === chunk.length ? chunk : chunk.subarray(0, size)];
92 }
93 }
94 // Provide writeSync for the sync fast path in pipeTo
95 const writer = { write() {}, writeSync() { return true; } };
96 await pipeTo(source(), writer);
97 }
98
99 (async () => {
100 bench.start();
101 for (let i = 0; i < n; i++) await run();
102 bench.end(totalOps);
103 })();
104}
105
106function benchIterSyncSource(chunk, datasize, n, totalOps) {
107 const { pipeTo } = 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