(filename)
| 50 | } |
| 51 | |
| 52 | function 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 | |
| 102 | async function run() { |
| 103 | for (let i = 0; i < benchmarks.length; ++i) { |
no test coverage detected
searching dependent graphs…