Recording a Performance Baseline
Before two timings can be compared, fix and record the machine, toolchain, build flags, input data, warmup, and measurement statistic. Treat the spread between identical runs as the noise floor and only claim differences that exceed it.
A performance baseline is a recorded measurement plus the conditions that produced it. The number alone is not the baseline. Two timings are comparable only when the machine, runtime, build, input, warmup, and statistic are the same, and when the observed difference is larger than the noise measured under those conditions.
The short answer
Fix everything except the variable under test, then record the fixed values next to the result. At minimum: hardware and core count, OS and kernel, runtime or compiler version, build flags, input dataset and seed, cache state, warmup, number of runs, and the reported statistic. Commit the baseline with the code revision it describes. Before trusting a comparison, run the same build twice; the spread between those runs is the noise floor.
| Dimension | Example to record | Why it changes the number |
|---|---|---|
| CPU and memory | model, cores, RAM | frequency, cache size, bandwidth |
| OS and kernel | version, governor | scheduling, power management |
| Toolchain | compiler or runtime version | code generation, JIT behavior |
| Build flags | -O2, debug symbols |
optimization level |
| Input | size, distribution, seed | algorithmic path and cache fit |
| Method | warmup, runs, statistic | startup cost, variance, tails |
A minimal example
hyperfine --warmup 3 --runs 20 \
--export-json baseline.json \
'./build/app --input data/medium.bin'
git rev-parse HEAD > baseline.meta
cc --version | head -n 1 >> baseline.meta
uname -a >> baseline.meta
Run the candidate in the same session, with the same command except for the change:
hyperfine --warmup 3 --runs 20 \
--export-json candidate.json \
'./build/app --input data/medium.bin'
Compare medians and the spread, not a single best time. If two runs of the identical binary differ by five percent, a three percent improvement is not evidence.
Why this happens
Performance is a property of the whole system. CPU frequency scaling, thermal state, page cache, allocator state, background processes, and measurement overhead all move the result. Run-to-run variance can exceed the effect being measured, especially on short benchmarks. Without a fixed protocol, a difference cannot be attributed to the code change rather than to the environment. Data layout compounds this: cache-line behavior means a small change in memory access can produce a large timing change.
What changes the answer
- Noise floor: measure it first; report effects only above it.
- CI machines: shared runners are heterogeneous. Pin the machine class, or compare only within one runner, and never across classes.
- Managed runtimes: JIT warmup and garbage collection dominate short runs; measure steady state and report GC time separately.
- I/O: state whether caches are warm or cold; both are valid, but they answer different questions.
- Duration: a benchmark shorter than the timer resolution measures noise. Repeat inside the timed region.
- Drift: interleave A and B runs in one session so thermal and load drift affects both.
Edge cases
Compilers can delete work whose result is unused; use a harness that consumes the result (black_box, DoNotOptimize). Constant inputs may be folded at compile time; read them at runtime. A mean hides tail latency, so report percentiles when latency matters. Concurrent benchmarks compete for cores and memory bandwidth. Virtualized and cloud hosts have noisy neighbors, which raises the noise floor.
Practical checks
Store the command, revision, machine identity, and raw samples with every baseline. Run A and B interleaved, repeat on a second machine before believing a small effect, and report the distribution rather than one number. In CI, fail a performance gate only when the regression exceeds the noise floor across multiple runs, and keep the baseline updated deliberately rather than automatically.
Sources
Revision history
- Published
- Updated
- — Initial publication.