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

Function benchCreation

benchmark/streams/compose.js:35–61  ·  view source on GitHub ↗
(n, numberOfPassThroughs)

Source from the content-addressed store, hash-verified

33}
34
35function benchCreation(n, numberOfPassThroughs) {
36 const cachedPassThroughs = [];
37 const cachedReadables = [];
38 const cachedWritables = [];
39
40 for (let i = 0; i < n; i++) {
41 const passThroughs = [];
42
43 for (let i = 0; i < numberOfPassThroughs; i++) {
44 passThroughs.push(new PassThrough());
45 }
46
47 const readable = Readable.from(['hello', 'world']);
48 const writable = new Writable({ objectMode: true, write: (chunk, encoding, cb) => cb() });
49
50 cachedPassThroughs.push(passThroughs);
51 cachedReadables.push(readable);
52 cachedWritables.push(writable);
53 }
54
55 bench.start();
56 for (let i = 0; i < n; i++) {
57 const composed = compose(cachedReadables[i], ...cachedPassThroughs[i], cachedWritables[i]);
58 composed.end();
59 }
60 bench.end(n);
61}
62
63function benchThroughput(n, numberOfPassThroughs, chunks) {
64 const chunk = Buffer.alloc(1024);

Callers 1

mainFunction · 0.85

Calls 6

composeFunction · 0.85
cbFunction · 0.50
pushMethod · 0.45
fromMethod · 0.45
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…