Why Your Micro Benchmarks Should Run for 300 Milliseconds

Benchmark in Milliseconds

A simple rule of thumb: tweak input size until a micro benchmark takes about 300ms. Milliseconds are easy to scan, avoid floating-point units, and are long enough to make fixed costs like interpreter startup irrelevant. Hundreds of milliseconds also sit in the human-perceptible range, so you can feel whether an optimization turned a lagging CLI command into something instant. Anything longer than a second just slows iteration, and the real goal is intuition, not precision.

The imminently-to-be-stated assumption here is that the purpose of benchmarking isn’t so much a precise measurement of performance, but rather providing the author with enough intuition to make a correct decision.

More from this day

2026-10-06