hyperfine
Benchmark command-line programs
TLDR
Run a basic benchmark, performing at least 10 runs
Run a comparative benchmark
Change minimum number of benchmarking runs
Perform benchmark with warmup
Run a command before each benchmark run (to clear caches, etc.)
Run a benchmark where a single parameter changes for each run
SYNOPSIS
hyperfine [OPTIONS] [--] <COMMAND> [<COMMAND> ...]
PARAMETERS
-h, --help
Prints help information.
-V, --version
Prints version information.
-n, --name
Sets custom name for the benchmark.
-w, --warmup
Number of warmup runs (default: 3).
-N, --runs
Exact number of runs; overrides auto-detection.
-r, --min-runs
Minimum number of runs (default: 10).
-R, --max-runs
Maximum number of runs (default: 100).
-m, --min-samples
Minimum samples for stability (default: 3 for mean/stddev).
--run-limit
Stop after NUM runs if stable.
-p, --prepare
Command run before each benchmark iteration.
-s, --setup
Command run once before all benchmarks.
-c, --cleanup
Command run once after all benchmarks.
--shell
Shell to use for command execution (default: /bin/sh).
-i, --ignore-failure
Continues benchmarking on command failure.
--show-output
Displays command output during runs.
--output
Output style: full, summary, csv, json (default: full).
--export-csv
Exports timings to CSV file.
--export-json
Exports timings to JSON file.
--export-markdown
Exports results to Markdown file.
--parameter-scan
Benchmarks with varying parameter values.
--time-unit
Time unit: s, ms, us, ns, min, h, d.
--style
Output style: auto, basic, fancy.
DESCRIPTION
Hyperfine is a command-line benchmarking tool for measuring execution times of shell commands with high accuracy and statistical rigor. It runs commands multiple times (default auto-determined between 10-100 runs), performs warmup iterations to stabilize caches, and computes robust statistics: mean, median, min, max, standard deviation, and percentiles (5%, 95%, 99%).
Key strengths include side-by-side comparison of multiple commands, custom naming for clarity, parameter sweeps via --parameter-scan, and preparation/setup/cleanup hooks. It uses the shell for command execution, supporting substitutions like $(pwd) or ${VAR}. Results display in human-readable tables or export to CSV, JSON, Markdown for analysis.
Robust against outliers via trimmed stats and stability checks. Ideal for optimizing scripts, CLI tools, or build processes. Cross-platform (Linux, macOS, Windows), lightweight Rust binary installable via cargo, brew, apt, etc. Handles failures gracefully with --ignore-failure.
CAVEATS
Measures wall-clock time (sensitive to system load, I/O); not CPU time. Requires stable environment for reliable results. Long-running commands may timeout implicitly.
EXAMPLE USAGE
Basic benchmark: hyperfine 'sleep 0.2' 'usleep 200000'
Named commands: hyperfine -n grep -n egrep '/bin/egrep' '/bin/grep'
Parameter scan: hyperfine --parameter-scan N 10 100 10 --runs 5 'sleep 0.3 && seq \$N'
INSTALLATION
Via Cargo: cargo install hyperfine
Debian/Ubuntu: apt install hyperfine
macOS: brew install hyperfine
HISTORY
Developed by David Peter (sharkdp) in Rust; first release 2017. Gained popularity via GitHub (20k+ stars), integrated into distros like Ubuntu/Debian EPEL since 2019.


