You've probably "benchmarked" something with time a couple of times and called it a day. The problem: one or two wall-clock readings tell you almost nothing. A background cron job, a cold page cache, or a busy neighbor on your shared machine can swing the numbers by more than the real difference you're chasing.
hyperfine fixes that. It's a command-line benchmarking tool by David Peter (sharkdp), the same author behind fd and bat. It's written in Rust, released under the Apache 2.0 license, and has been around since early 2018 - it has gathered well over 25,000 stars on GitHub and ships frequent releases (the current one is v1.21.0). It runs on Linux, macOS, and Windows.
What makes it different
Give it one command and it takes over from there:
hyperfine 'sleep 0.5'
It automatically decides how many runs to perform - by default at least 10, targeting roughly three seconds of total runtime - then reports mean, standard deviation, min, and max. Instead of trusting two lucky samples, you get a real spread, and a modified Z-score pass flags genuine outliers. When it warns you about an unusually slow first run, you know to add warmup; when it warns about outliers, it's telling you your machine is noisy, not your tool.
Warmup, clean state, and comparison
For disk-heavy tools, results depend on whether caches are warm or cold. hyperfine lets you control both:
hyperfine --warmup 3 'sleep 0.5'
That runs the command three times untimed to warm the page cache before measuring. For the opposite - a guaranteed cold cache - use --prepare to run a command before each timed sample.
Comparing two tools is where it shines, and it's the author's own demo:
hyperfine 'fd' 'find'
The relative column tells you how many times faster one is than the other, with error bars on the ratio.
Parameter sweeps and clean exports
Want to see how timing scales as a value changes? Use a parameter scan:
hyperfine --parameter-scan time 1 5 'sleep {time}'
It substitutes each value and builds a family of results. And when you want to share numbers, results export to CSV, JSON, Markdown, or AsciiDoc:
hyperfine --export-markdown results.md 'command'
One more nicety: the -N flag skips the shell entirely so hyperfine times your binary directly, dropping shell-startup noise for sub-5ms commands.
Getting it and when to use it
Install from source with cargo install --locked hyperfine (you'll want a recent Rust toolchain), grab a prebuilt .deb from the GitHub releases page, or use your distro's package manager - apt, Homebrew, pacman, and winget all carry it.
Reach for hyperfine whenever you need a defensible "is A faster than B?" answer. For microsecond-scale work inside one process, a proper in-process profiler fits better - but for comparing whole command-line tools, hyperfine is the de-facto modern choice.
