← All posts

CLI

hyperfine: Benchmark Any Command With Real Statistics

hyperfine is a command-line benchmarking tool that runs commands repeatedly and reports statistically sound timings.

H CLI

"Is this faster?" is a question developers answer badly. We run a command once, eyeball the time, and convince ourselves. hyperfine replaces that with actual measurement. It runs a command many times, warms up caches, discards outliers, and reports a mean with standard deviation - and it can run several commands and tell you which is faster and by how much, with the statistics to back it up.

Measure, Don't Guess

Point it at one command for a solid timing, or at several to compare them head to head:

# Benchmark a single command hyperfine 'grep -r TODO .' # Compare two approaches directly hyperfine 'grep -r TODO .' 'rg TODO' # Warm up first, then measure hyperfine --warmup 3 './build.sh'

Honest Numbers

Because it handles warmup runs, statistical outliers, and multiple samples, the numbers it gives are ones you can actually cite. It can export results to JSON, CSV, or Markdown for a report, and parameter sweeps let you benchmark the same command across a range of inputs.

Rough Edges and Limitations

  • Whole-command timing. It measures end to end, not where inside a program the time goes - profilers do that.
  • Noise is real. A busy machine skews results; benchmark on a quiet system.
  • Short commands mislead. Sub-millisecond commands are dominated by process startup, not the work.

Next time you're about to claim one approach is faster, hyperfine turns the claim into a measurement in about ten seconds.

Internal link suggestion: link "which is faster" to the ripgrep post, a natural thing to benchmark against grep.