| 93 | } |
| 94 | |
| 95 | function runBenchmark(n) { |
| 96 | return new Promise((resolve, reject) => { |
| 97 | const child = fork( |
| 98 | fullBenchmarkPath, |
| 99 | [`n=${n}`], |
| 100 | { stdio: ['inherit', 'pipe', 'inherit', 'ipc'] }, |
| 101 | ); |
| 102 | |
| 103 | const results = []; |
| 104 | child.on('message', (data) => { |
| 105 | if (data.type === 'report' && data.rate && data.conf) { |
| 106 | results.push({ |
| 107 | rate: data.rate, |
| 108 | conf: data.conf, |
| 109 | }); |
| 110 | } |
| 111 | }); |
| 112 | |
| 113 | child.on('close', (code) => { |
| 114 | if (code !== 0) { |
| 115 | reject(new Error(`Benchmark exited with code ${code}`)); |
| 116 | } else { |
| 117 | resolve(results); |
| 118 | } |
| 119 | }); |
| 120 | }); |
| 121 | } |
| 122 | |
| 123 | async function main(n = startN) { |
| 124 | let increaseCount = 0; |