Benchmarks
KSail includes automated benchmark regression testing to detect performance changes in pull requests that modify Go code.
Performance Trends
Section titled “Performance Trends”Loading benchmark data…
Regression Detection
Section titled “Regression Detection”| Setting | Value | Meaning |
|---|---|---|
alert-threshold | 150% | Marks benchmarks as regressed in the PR comment and fails pull request CI when ≥1.5× slower than baseline |
fail-threshold | 200% | Fails CI on non-PR runs such as pushes to main when a benchmark is ≥2× slower than baseline |
On pull requests where benchmarks run and benchmark functions are discovered, a comment is posted only when the alert threshold is exceeded, highlighting the regressed benchmarks.
Benchmark results are also recorded in every CI workflow run summary. On pushes to main, results are auto-pushed to the benchmark-data branch.
Running Benchmarks Locally
Section titled “Running Benchmarks Locally”# Run all benchmarksgo test -bench=. -benchmem -run='^$' ./...
# Run a specific packagego test -bench=. -benchmem -run='^$' ./pkg/k8s/readiness/...Writing Effective Benchmarks
Section titled “Writing Effective Benchmarks”- Call
b.ReportAllocs()to track allocations - Use
b.ResetTimer()after expensive setup - Use
for b.Loop()style (Go 1.26+) - Use
b.TempDir()for reproducible temp files - Use table-driven scenarios to cover multiple input sizes
- Fail fast with
b.Fatalfon unexpected errors - Avoid
time.Sleep()inside benchmark loops — measure real CPU work, not timers