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

Function benchFromFirstBatch

benchmark/streams/iter-from-batching.js:47–67  ·  view source on GitHub ↗
(chunks, chunkSize, n)

Source from the content-addressed store, hash-verified

45}
46
47function benchFromFirstBatch(chunks, chunkSize, n) {
48 const { from } = require('stream/iter');
49 const chunk = new Uint8Array(chunkSize);
50 let seen = 0;
51
52 (async () => {
53 bench.start();
54 for (let i = 0; i < n; i++) {
55 const iterator = from(source(chunks, chunk))[Symbol.asyncIterator]();
56 const { value, done } = await iterator.next();
57 if (done || value.length === 0) {
58 throw new Error('expected a batch');
59 }
60 seen += value.length;
61 }
62 bench.end(n);
63 if (seen === 0) {
64 throw new Error('expected chunks');
65 }
66 })();
67}
68
69function benchFromSyncWritev(chunks, chunkSize, n) {
70 const { pipeToSync } = require('stream/iter');

Callers 1

mainFunction · 0.85

Calls 6

sourceFunction · 0.70
nextMethod · 0.65
requireFunction · 0.50
fromFunction · 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…