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

Function main

benchmark/streams/iter-throughput-share.js:14–32  ·  view source on GitHub ↗
({ consumers, batches, backpressure, n })

Source from the content-addressed store, hash-verified

12});
13
14async function main({ consumers, batches, backpressure, n }) {
15 const { share, array } = require('stream/iter');
16 const chunk = Buffer.alloc(1024);
17 const totalOps = batches * consumers * n;
18
19 async function* source() {
20 for (let i = 0; i < batches; i++) {
21 yield [chunk];
22 }
23 }
24
25 bench.start();
26 for (let i = 0; i < n; i++) {
27 const shared = share(source(), { highWaterMark: 64, backpressure });
28 const readers = Array.from({ length: consumers }, () => array(shared.pull()));
29 await Promise.all(readers);
30 }
31 bench.end(totalOps);
32}

Callers

nothing calls this directly

Calls 10

shareFunction · 0.85
allocMethod · 0.80
allMethod · 0.80
sourceFunction · 0.70
requireFunction · 0.50
arrayFunction · 0.50
startMethod · 0.45
fromMethod · 0.45
pullMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…