MCPcopy Create free account
hub / github.com/modem-dev/hunk / formatComparisonMarkdown

Function formatComparisonMarkdown

scripts/compare-release-benchmarks.ts:322–359  ·  view source on GitHub ↗
(
  comparison: BenchmarkComparisonResult,
  options: { baseLabel: string; headLabel: string },
)

Source from the content-addressed store, hash-verified

320
321/** Render a compact Markdown report suitable for GitHub Actions summaries. */
322export 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
361function readArgValue(args: string[], index: number) {
362 const value = args[index + 1];

Callers 2

mainFunction · 0.85

Calls 4

formatUnitFunction · 0.85
formatNumberFunction · 0.85
formatDeltaPercentFunction · 0.85
formatThresholdFunction · 0.85

Tested by

no test coverage detected