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

Function main

benchmark/child_process/child-process-read.js:20–42  ·  view source on GitHub ↗
({ dur, len })

Source from the content-addressed store, hash-verified

18});
19
20function main({ dur, len }) {
21 bench.start();
22
23 const msg = `"${'.'.repeat(len)}"`;
24 const options = { 'stdio': ['ignore', 'pipe', 'ignore'] };
25 const child = child_process.spawn('yes', [msg], options);
26
27 let bytes = 0;
28 child.stdout.on('data', (msg) => {
29 bytes += msg.length;
30 });
31
32 setTimeout(() => {
33 if (process.platform === 'win32') {
34 // Sometimes there's a yes.exe process left hanging around on Windows...
35 child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
36 } else {
37 child.kill();
38 }
39 const gbits = (bytes * 8) / (1024 * 1024 * 1024);
40 bench.end(gbits);
41 }, dur * 1000);
42}

Callers

nothing calls this directly

Calls 5

killMethod · 0.80
setTimeoutFunction · 0.50
startMethod · 0.45
onMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…