Gem benchmarkingcli

hyperfine

Benchmark any shell command with proper statistics.

Would you recommend hyperfine?

No votes yet. Tried it? Be the first to say.

One vote per person. No account needed.

Overview

hyperfine runs commands repeatedly with warmup, reports mean and spread, detects outliers and compares several commands side by side. It can export Markdown and JSON.

Instead of

Running `time` once and trusting it

Reach for it when

You want to know whether a change actually made a build, script or CLI faster.

Key features

  • Statistical runs

    Runs a command many times and reports mean, standard deviation, min, max and outliers.

  • Warmup and preparation

    --warmup runs to fill caches, and --prepare runs a setup command before each timing (for example clearing a build cache).

  • Side-by-side comparison

    Benchmark several commands at once and get a "X is 2.3× faster than Y" summary.

  • Parameter scans

    -P threads 1 8 or -L compiler gcc,clang runs a matrix of variants.

  • Exports

    Markdown, JSON, CSV and AsciiDoc output, ready for PR descriptions or charts.

  • Shell overhead correction

    Measures and subtracts shell start-up time, or skips the shell entirely with -N.

In depth

Example: compare two builds and publish the result

bash
hyperfine --warmup 2 --runs 10 \
  --prepare 'rm -rf dist' \
  'npm run build' 'bun run build' \
  --export-markdown bench.md

The output shows each command's mean ± σ, the range, and a relative summary. bench.md contains a table you can paste into a PR.

Parameter scans

bash
# How does a build scale with parallel jobs?
hyperfine --prepare 'make clean' -P threads 1 8 'make -j {threads}'

# Compare named variants
hyperfine -L tool rg,grep '{tool} -r "TODO" .'

Getting reliable numbers

  • Use --warmup for anything that touches disk caches, and --prepare to reset state when you want cold-cache numbers.
  • Watch the "outliers" warning; it usually means something else was competing for the CPU.
  • Export JSON (--export-json) to keep historical results or plot them.

Strengths

  • Gives you numbers you can trust, with variance, instead of one noisy time result.
  • Perfect for settling "is the new version actually faster?" debates in a pull request.
  • Easy to use on any command, in any language, with no code changes.

Watch out for

  • It measures whole-process wall-clock time, not individual functions; use an in-language benchmark library for micro-benchmarks.
  • Background load (browsers, indexing, CPU throttling on laptops) adds noise, so close things or use a quiet machine.
  • For very fast commands, use -N and more runs, or the noise dominates.

Try it in a few minutes

Terminal
brew install hyperfine   # or cargo install hyperfine
hyperfine --warmup 2 'npm run build' 'bun run build'

Alternatives

time

Built into every shell, but a single sample with no statistics.

In-code benchmark libraries (Vitest bench, criterion, BenchmarkDotNet)

Better for measuring functions rather than whole commands.

poop

A Linux-only tool that adds hardware counters like cache misses and instructions.

Related tools

Other tools that share topics with hyperfine.

Atuin

atuin.sh
Gem

Searchable shell history with context, and optional encrypted sync between machines.

Instead of Ctrl-R and a ~/.bash_history that loses commands

mise

mise.jdx.dev
Gem

One tool to pin Node, Python, Go and more per project, plus env vars and tasks.

Instead of nvm + pyenv + asdf + direnv + ad-hoc scripts

llm (CLI)

llm.datasette.io
Gem

Use LLMs from the command line and pipe anything into them.

Instead of Copy-pasting terminal output into a chat window