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

Function runBenchmark

benchmark/run.js:52–100  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

50}
51
52function runBenchmark(filename) {
53 const scriptPath = path.resolve(__dirname, filename);
54
55 const args = cli.test ? ['--test'] : cli.optional.set;
56 const cpuCore = cli.getCpuCoreSetting();
57 let child;
58 if (cpuCore !== null) {
59 child = spawn('taskset', ['-c', cpuCore, 'node', scriptPath, ...args], {
60 stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
61 });
62 } else {
63 child = fork(
64 scriptPath,
65 args,
66 );
67 }
68
69 return new Promise((resolve, reject) => {
70 child.on('message', (data) => {
71 if (data.type !== 'report') {
72 return;
73 }
74 // Construct configuration string, " A=a, B=b, ..."
75 let conf = '';
76 for (const key of Object.keys(data.conf)) {
77 if (conf !== '')
78 conf += ' ';
79 conf += `${key}=${JSON.stringify(data.conf[key])}`;
80 }
81 if (format === 'csv') {
82 // Escape quotes (") for correct csv formatting
83 conf = conf.replace(/"/g, '""');
84 console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`);
85 } else {
86 let rate = data.rate.toString().split('.');
87 rate[0] = rate[0].replace(/(\d)(?=(?:\d\d\d)+(?!\d))/g, '$1,');
88 rate = (rate[1] ? rate.join('.') : rate[0]);
89 console.log(`${data.name} ${conf}: ${rate}`);
90 }
91 });
92 child.once('close', (code) => {
93 if (code) {
94 reject(code);
95 } else {
96 resolve(code);
97 }
98 });
99 });
100}
101
102async function run() {
103 for (let i = 0; i < benchmarks.length; ++i) {

Callers 1

runFunction · 0.70

Calls 12

keysMethod · 0.65
spawnFunction · 0.50
forkFunction · 0.50
rejectFunction · 0.50
resolveFunction · 0.50
resolveMethod · 0.45
onMethod · 0.45
logMethod · 0.45
splitMethod · 0.45
toStringMethod · 0.45
joinMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…