| 158 | } |
| 159 | |
| 160 | function buildHyperfineCommand( |
| 161 | command: string, |
| 162 | warmup: number, |
| 163 | runs: number, |
| 164 | prepare: string | undefined, |
| 165 | ignoreFailure: boolean, |
| 166 | showOutput: boolean, |
| 167 | exportJson: string | undefined, |
| 168 | ): string { |
| 169 | const parts: string[] = ["hyperfine"]; |
| 170 | |
| 171 | if (warmup > 0) { |
| 172 | parts.push("--warmup", String(warmup)); |
| 173 | } |
| 174 | |
| 175 | parts.push("--runs", String(runs)); |
| 176 | |
| 177 | if (prepare !== undefined) { |
| 178 | parts.push("--prepare", `'${prepare}'`); |
| 179 | } |
| 180 | |
| 181 | if (ignoreFailure) { |
| 182 | parts.push("--ignore-failure"); |
| 183 | } |
| 184 | |
| 185 | if (showOutput) { |
| 186 | parts.push("--show-output"); |
| 187 | } |
| 188 | |
| 189 | if (exportJson !== undefined) { |
| 190 | parts.push("--export-json", `'${exportJson}'`); |
| 191 | } |
| 192 | |
| 193 | parts.push(`'${command}'`); |
| 194 | |
| 195 | return parts.join(" "); |
| 196 | } |
| 197 | |
| 198 | if (import.meta.main) { |
| 199 | await cliMain(); |