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

Function benchIter

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

Source from the content-addressed store, hash-verified

95}
96
97function benchIter(chunk, datasize, n, totalOps) {
98 const { pipeTo } = require('stream/iter');
99
100 const upper = (chunks) => {
101 if (chunks === null) return null;
102 return chunks.map((c) => copyBuf(c));
103 };
104
105 async function run() {
106 let remaining = datasize;
107 async function* source() {
108 while (remaining > 0) {
109 const size = Math.min(remaining, chunk.length);
110 remaining -= size;
111 yield [size === chunk.length ? chunk : chunk.subarray(0, size)];
112 }
113 }
114 await pipeTo(source(), upper,
115 { write() {}, writeSync() { return true; } });
116 }
117
118 (async () => {
119 bench.start();
120 for (let i = 0; i < n; i++) await run();
121 bench.end(totalOps);
122 })();
123}
124
125function benchIterSync(chunk, datasize, n, totalOps) {
126 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…