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

Function benchFromSyncWritev

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

Source from the content-addressed store, hash-verified

67}
68
69function benchFromSyncWritev(chunks, chunkSize, n) {
70 const { pipeToSync } = require('stream/iter');
71 const chunk = new Uint8Array(chunkSize);
72 const expected = chunks * chunkSize * n;
73 let seen = 0;
74 let total = 0;
75 const fd = openSync(devNull, 'w');
76 const writer = {
77 writeSync(chunk) {
78 writeSync(fd, chunk);
79 seen++;
80 },
81 writevSync(batch) {
82 writevSync(fd, batch);
83 seen += batch.length;
84 },
85 };
86
87 try {
88 bench.start();
89 for (let i = 0; i < n; i++) {
90 total += pipeToSync(source(chunks, chunk), writer);
91 }
92 bench.end(chunks * n);
93 } finally {
94 closeSync(fd);
95 }
96
97 if (total !== expected || seen !== chunks * n) {
98 throw new Error('unexpected chunk count');
99 }
100}

Callers 1

mainFunction · 0.85

Calls 7

pipeToSyncFunction · 0.85
sourceFunction · 0.70
requireFunction · 0.50
openSyncFunction · 0.50
closeSyncFunction · 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…