We've all been there. A rewrite lands, someone asks "is it faster?", you run the new binary once, squint at the wall clock, and declare victory. Deep down you know a single time run isn't evidence — it's a coin flip dressed up as a benchmark. hyperfine is a command-line tool built to take that dishonesty away from you.
It's from David Peter (the sharkdp who brought you fd and bat), first released in 2018 and now sitting at more than 28,000 GitHub stars. With one command you hand it the things you want to compare, and it does the rest: run each one many times, compute mean and standard deviation, flag outliers, and print a table with a winner in bold.
Why time wasn't doing the job
The shell's time keyword gives you a single measurement of a single run. All the noise from scheduler jitter, disk caches, and whatever else the machine happened to be doing is baked straight into the number. hyperfine attacks change at both ends: it runs many times and reports statistical aggregates, and it automatically detects outliers so one stray run doesn't skew the story.
By default it performs at least ten benchmarking runs and measures for at least three seconds — it tunes the run count to the command rather than hoping you picked a sensible number.
In practice
Comparing two programs is as simple as passing both:
$ hyperfine 'hexdump file' 'xxd file'
The first command becomes the reference; every later row shows how far off the reference it is.
Cold cache skews are a real problem for anything doing disk I/O, so you get two handles on it. --warmup 3 runs the command a few times before timing, so you measure a warm cache. -p runs a prepare command before each timed run — the classic move is -p 'sync' to flush the page cache and measure the cold start. Same benchmark, honest in either direction.
For comparing a program across a parameter sweep — say thread counts — -P gives you parameterized benchmarks:
$ hyperfine -P threads 1 8 'my_program --threads {threads}'
The missing tool here is making results checkable. --export-json spits out structured results, and there are integrations that build on top of them. Bencher tracks benchmarks continuously and can catch a performance regression in CI the moment it lands, and Chronologer will visualize how your timings drift across Git history. Your benchmark stops being a one-off "is it faster" moment and becomes something you can hand to a CI job.
Getting it and getting the results out
Installation is unglamorous and everywhere: apt install hyperfine, dnf install hyperfine, pacman -S hyperfine, or via Homebrew and cargo install. There are prebuilt binaries for Linux, macOS, and Windows. It runs on all three with the same behavior — a genuinely cross-platform tool, not a Linux afterthought.
A few things worth knowing about the current release. The 2.0 rewrite changed how it invokes things: benchmarked commands now run directly by default (--shell=none), which is faster and removes a layer of parsing surprises, and the JSON export format was redone. If you have scripts that parse --export-json output, check the schema version; the 1.x field layout moved under a summary object.
The takeaway
Precise tools don't make the work elegant — they make it honest. hyperfine won't tell you your code is fast; it tells you what it can actually prove about your code, which is more useful and a lot more than most of us were measuring before. Run it once, and the single-run time forever smells like what it is: a guess.
Install it, point it at two plausible alternatives, and let yourself be wrong for once. The numbers will sort you out quickly either way.