← Back to docs

Recipe: Performance PR summary writer

Automate perf-regression summaries from benchmark diffs so every PR ships with a human-readable impact statement.

Ingredients

  • Benchmark harness output (JSON or CSV)
  • Baseline snapshot from main
  • Threshold config (p50 / p99 / memory)
  • Markdown template

Steps

  1. Run the benchmark suite on both the base commit and the PR head.
  2. Diff the two result sets, grouping by benchmark name.
  3. Flag any metric that exceeds the configured threshold (default: 3% regress, 5% improve).
  4. Render a Markdown table with columns: benchmark, base, head, delta, and a “verdict” emoji.
  5. Prepend a one-sentence executive summary.
  6. Post the summary as a PR comment via the CI provider’s API.

Example output

## Perf summary (PR #142)
          
**Net change: +1.2% p50 latency, no memory regressions.**

| Benchmark       | Base   | Head   | Delta  | Verdict |
|-----------------|--------|--------|--------|---------|
| login_p50       | 42 ms  | 43 ms  | +2.4%  | ⚠️      |
| checkout_p99    | 210 ms | 208 ms | -1.0%  | ✅      |
| mem_rss_peak    | 98 MB  | 97 MB  | -1.0%  | ✅      |

CI integration

Wire the script into your GitHub Actions or GitLab CI pipeline. Use the provider’s token to call the comments API. Fail the check only when a critical regression (default: >10%) is detected.