Skip to content

Benchmarks

KSail includes automated benchmark regression testing to detect performance changes in pull requests that modify Go code.

Loading benchmark data…

SettingValueMeaning
alert-threshold150%Marks benchmarks as regressed in the PR comment and fails pull request CI when ≥1.5× slower than baseline
fail-threshold200%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.

Terminal window
# Run all benchmarks
go test -bench=. -benchmem -run='^$' ./...
# Run a specific package
go test -bench=. -benchmem -run='^$' ./pkg/k8s/readiness/...
  • 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.Fatalf on unexpected errors
  • Avoid time.Sleep() inside benchmark loops — measure real CPU work, not timers