Why 99% of C++ Microbenchmarks Lie – and How to Write the 1% that Matter!
Kris Jusiak
These are notes from Kris Jusiak's CppCon 2025 talk. Kris is the author of [Boost].UT and has long worked on compile-time computation and testing frameworks. The talk zeroes in on a frustrating question: you write a benchmark, get a beautiful nanosecond number, optimize against it, ship — and production is unchanged, or even slower. Kris's answer is blunt: your benchmark is almost certainly lying, and not in one place — several lies chained together.
The notes are split into five parts, peeling liars off layer by layer: first the compiler deleting your loop entirely, then noise and bias as two fundamentally different kinds of error, then the branch predictor and cache conspiring to flatter your numbers, then latency vs. throughput as two dimensions people conflate, and finally the cruelest one — a faster microbenchmark is not the same as a faster program.
About the local environment
All experiments in this series were run on the same machine: Arch Linux / WSL2, AMD Ryzen 7 9700X (Zen 5), GCC 16.1.1, -std=c++20. This box has no CPU pinning, no locked frequency, no quieted background — it is a plain WSL2 setup, which means noise is larger than on a properly tuned machine. That happens to make "what does noise look like" easier to see. Your numbers will differ; the direction of the conclusions will not.