(
comparison: BenchmarkComparisonResult,
options: { baseLabel: string; headLabel: string },
)
| 320 | |
| 321 | /** Render a compact Markdown report suitable for GitHub Actions summaries. */ |
| 322 | export function formatComparisonMarkdown( |
| 323 | comparison: BenchmarkComparisonResult, |
| 324 | options: { baseLabel: string; headLabel: string }, |
| 325 | ) { |
| 326 | const failedRows = comparison.rows.filter( |
| 327 | (row) => row.status === "fail" || row.status === "missing-head", |
| 328 | ); |
| 329 | const lines = [ |
| 330 | "## Release benchmark gate", |
| 331 | "", |
| 332 | comparison.failed |
| 333 | ? `❌ ${failedRows.length} material benchmark regression${failedRows.length === 1 ? "" : "s"} found.` |
| 334 | : "✅ No unaccepted material benchmark regressions found.", |
| 335 | "", |
| 336 | `Base: \`${options.baseLabel}\` `, |
| 337 | `Head: \`${options.headLabel}\``, |
| 338 | "", |
| 339 | "| Status | Metric | Base median | Head median | Δ | Threshold |", |
| 340 | "| --- | --- | ---: | ---: | ---: | --- |", |
| 341 | ]; |
| 342 | |
| 343 | for (const row of comparison.rows) { |
| 344 | const unit = formatUnit(row.unit); |
| 345 | const status = |
| 346 | row.status === "fail" || row.status === "missing-head" |
| 347 | ? "❌" |
| 348 | : row.status === "accepted" |
| 349 | ? "⚠️" |
| 350 | : "✅"; |
| 351 | lines.push( |
| 352 | `| ${status} ${row.status} | \`${row.name}\` | ${formatNumber(row.baseMedian)} ${unit} | ${formatNumber( |
| 353 | row.headMedian, |
| 354 | )} ${unit} | ${formatDeltaPercent(row.relativeDelta)} | ${formatThreshold(row.threshold, row.unit)} |`, |
| 355 | ); |
| 356 | } |
| 357 | |
| 358 | return `${lines.join("\n")}\n`; |
| 359 | } |
| 360 | |
| 361 | function readArgValue(args: string[], index: number) { |
| 362 | const value = args[index + 1]; |
no test coverage detected