(script: string)
| 121 | } |
| 122 | |
| 123 | async function runScript(script: string) { |
| 124 | const proc = Bun.spawn(["bun", "run", `benchmarks/${script}`], { |
| 125 | stdout: "pipe", |
| 126 | stderr: "pipe", |
| 127 | stdin: "ignore", |
| 128 | env: { ...process.env, CI: process.env.CI ?? "1" }, |
| 129 | }); |
| 130 | |
| 131 | const [stdout, stderr, exitCode] = await Promise.all([ |
| 132 | new Response(proc.stdout).text(), |
| 133 | new Response(proc.stderr).text(), |
| 134 | proc.exited, |
| 135 | ]); |
| 136 | |
| 137 | if (stderr.trim()) { |
| 138 | console.warn(stderr.trim()); |
| 139 | } |
| 140 | |
| 141 | if (exitCode !== 0) { |
| 142 | throw new Error(`${script} failed with exit code ${exitCode}\n${stderr}`); |
| 143 | } |
| 144 | |
| 145 | process.stdout.write(stdout); |
| 146 | return parseMetrics(stdout); |
| 147 | } |
| 148 | |
| 149 | function formatValue(value: number) { |
| 150 | if (Math.abs(value) >= 100) { |
no test coverage detected