hyperfine

A command-line benchmarking tool that runs commands multiple times and produces statistical summaries with warmup support and outlier detection.

Screenshot of hyperfine

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 hyperfine

Usage

# 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:

CommandMeanMinMaxRelative
fd -e rs14.2 ms13.8 ms15.1 ms1.00
find . -name "*.rs"58.7 ms56.2 ms63.4 ms4.13