Favicon of hyperfine

hyperfine

Hyperfine is a Rust CLI tool for benchmarking shell commands with statistical analysis, warmup runs, and CSV/JSON/Markdown export.

hyperfine website screenshot
hyperfine GitHub repository preview

Hyperfine is a command-line benchmarking tool written in Rust. It's for developers, sysadmins, and anyone who needs to compare the performance of commands, scripts, or binaries without writing a custom timing harness. Instead of running time in a loop and doing math by hand, you point hyperfine at one or more commands and it handles repeated runs, statistics, and outlier detection for you.

The tool runs each command directly by default (no shell overhead), though you can opt into shell execution with -S when you need pipes, redirects, or wildcards. It automatically figures out how many runs to perform based on a target duration, or you can set an exact count. When comparing multiple commands, the first one becomes the baseline and later results show percentage change and speedup factor relative to it.

Key features

  • Statistical analysis: runs each command multiple times and reports mean, standard deviation, min/max, with automatic outlier detection to flag interference from caching or background processes.
  • Multiple metrics: beyond wall-clock time, it can report CPU time (user/system), peak memory (RSS), and hardware counters like CPU cycles, instructions, cache references/misses, and branch misses (Linux/macOS, no shell).
  • Warmup and cache control: --warmup runs a command a few times before measuring (warm cache), and --prepare runs a setup command before every measured run (useful for cold-cache or clean-state benchmarks).
  • Parameterized benchmarks: --parameter-scan and --parameter-list let you sweep a numeric range or a list of values (thread counts, compilers, git branches) across a template command.
  • Setup/cleanup hooks: --setup, --conclude, and --cleanup commands run outside the measured window, so one-time work (like switching git branches) doesn't pollute the timing.
  • Shell flexibility: choose no shell (fastest, default), the platform default shell with -S, or a specific shell like zsh or bash (including exported shell functions).
  • Environment variable injection: --env sets variables per command or globally, and supports parameter placeholders.
  • Export formats: CSV, JSON, Markdown, AsciiDoc, and org-mode, with helper Python scripts in the repo for histograms and whisker plots from JSON output.
  • Cross-platform: runs on Linux, macOS, and Windows, though hardware counters and peak memory have platform-specific limitations.

Ideal use cases

Hyperfine fits well when you're comparing two or more implementations of the same task: two CLI tools that do the same job (like find vs fd), two compiler flags, two versions of a script, or performance across git branches using --setup 'git switch {branch}'. It's also useful for tracking down regressions in build scripts or CI pipelines where you want a quick, statistically sound comparison without building custom tooling.

It's a good fit for benchmarking short-to-medium running commands (milliseconds to seconds) where shell startup overhead or system noise could otherwise distort results, since hyperfine corrects for shell spawn time and flags outliers.

It is not the right tool for profiling where time is spent inside a single process (use a profiler for that), nor for benchmarking long-running services or workloads that need sustained load testing over minutes or hours. It's also not designed for microbenchmarking at the sub-millisecond level inside application code; that's better handled by language-specific benchmarking frameworks.

Installation

Hyperfine is packaged for most major platforms. A few common options:

Linux (Debian/Ubuntu):

apt install hyperfine

Fedora:

dnf install hyperfine

Arch Linux:

pacman -S hyperfine

macOS (Homebrew):

brew install hyperfine

Windows (Winget):

winget install hyperfine

From source with cargo (Linux, macOS, Windows), requires Rust 1.97 or newer:

cargo install --locked hyperfine

You can also install via conda-forge, Flox, Chocolatey, Scoop, or download a prebuilt binary from the GitHub Releases page. After installing, run a basic benchmark to confirm it works:

hyperfine 'sleep 0.3'

Frequently asked questions

Share:

Stars
29.1K
Forks
609
Last commit
7 days ago
Repository age
9 years
License
Apache-2.0
Self-hosted
No
Activity score
81/100
View Repository
Built with:
Ad
Favicon

 

  
 

Similar to hyperfine

Favicon

 

  
 
Favicon

 

  
 
Favicon