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

Function benchIterSyncSource

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

Source from the content-addressed store, hash-verified

104}
105
106function benchIterSyncSource(chunk, datasize, n, totalOps) {
107 const { pipeTo } = require('stream/iter');
108
109 async function run() {
110 let remaining = datasize;
111 function* source() {
112 while (remaining > 0) {
113 const size = Math.min(remaining, chunk.length);
114 remaining -= size;
115 yield size === chunk.length ? chunk : chunk.subarray(0, size);
116 }
117 }
118 const writer = { write() {}, writeSync() { return true; } };
119 await pipeTo(source(), writer);
120 }
121
122 (async () => {
123 bench.start();
124 for (let i = 0; i < n; i++) await run();
125 bench.end(totalOps);
126 })();
127}
128
129function benchIterSync(chunk, datasize, n, totalOps) {
130 const { pipeToSync } = require('stream/iter');

Callers 1

mainFunction · 0.85

Calls 4

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

Tested by

no test coverage detected