Documentation
¶
Overview ¶
Command benchgate fails when benchmarks regressed. It reads the CSV output of `benchstat -format csv base.txt head.txt` on stdin, prints every regression, and exits 1 if there is one.
A benchmark regressed when benchstat calls the difference significant (the "vs base" column is a percentage, not "~") and the head is slower, or uses more memory or allocations, by more than -threshold percent. Requiring significance keeps noise on shared CI runners from failing pull requests; the threshold keeps tiny but real changes from doing so (0001 §8: 5%).
Below -fast-below per op (1 µs), time is gated at -fast-threshold (25%) instead: where the compiler and linker place a benchmark's code moves such a benchmark by up to ~15% with no change in what it runs (#413, #428, #422), because alignment and branch-predictor aliasing weigh on a few hundred nanoseconds. Their bytes and allocations per op keep -threshold: layout doesn't change those. docs/design/0001 §8 says how to tell a layout shift from a real regression.
Regressions are keyed by package, benchmark and unit. -flagged writes the keys found, one "pkg<TAB>benchmark<TAB>unit" line each. -confirm reads such a file from an earlier run and fails only on regressions that are in it as well, so a regression must show on two independent runs: real ones repeat, noise mostly does not.