hyperfine
A command-line benchmarking tool that runs commands multiple times and produces statistical summaries with warmup support and outlier detection.
hyperfine is a statistical command-line benchmarking tool. Where the humble
time command gives you a single measurement, hyperfine runs your command
dozens of times, warms up the filesystem cache, detects outliers, and gives you
mean, standard deviation, min, and max — all with a live progress bar and a
summary table at the end.
It's the go-to tool for any situation where you want to answer "which of these two approaches is actually faster?" with confidence.
Features
- Statistical rigour — runs commands many times and reports mean ± stddev, min, max, and median
- Warmup runs — optionally pre-run commands to fill filesystem/CPU caches before measuring
- Multiple commands — benchmark several commands side-by-side and get a ranked comparison table
- Parameterised benchmarks — sweep over a range of values with
--parameter-scan - Export results — output to JSON, CSV, Markdown, or AsciiDoc for use in reports or CI
- Shell-independent — benchmarks run without a shell by default for more consistent results
- Outlier detection — warns you when results have unusually high variance
Installation
cargo install hyperfine
Or via your system package manager:
# Debian/Ubuntu
apt install hyperfine
# macOS
brew install hyperfine
# Arch Linux
pacman -S hyperfineUsage
# Basic benchmark
hyperfine 'sleep 0.3'
# Compare two commands
hyperfine 'fd -e rs' 'find . -name "*.rs"'
# Warmup runs before measuring
hyperfine --warmup 5 'grep -r TODO .'
# Sweep over a parameter
hyperfine --parameter-scan size 100 1000 -D 100 \
'seq {size} | sort'
# Export results to JSON
hyperfine --export-json results.json 'rg pattern' 'grep -r pattern'
# Set minimum number of runs
hyperfine --min-runs 20 'cargo check'Example Output
Running hyperfine 'fd -e rs' 'find . -name "*.rs"' produces a table like:
| Command | Mean | Min | Max | Relative |
|---|---|---|---|---|
fd -e rs | 14.2 ms | 13.8 ms | 15.1 ms | 1.00 |
find . -name "*.rs" | 58.7 ms | 56.2 ms | 63.4 ms | 4.13 |