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|-c] COMMAND...
PARAMETERS
--help
Display help message and exit.
--version
Show version and exit.
--command, -c COMMAND
Command to benchmark. This option can be used multiple times to compare different commands. If used once, it will be run as a single command.
--warmup N
Number of warmup runs. These runs are executed before the actual benchmark to reduce any initial overhead.
--min-runs N
Minimum number of benchmark runs (default: 10). Hyperfine will execute the commands at least this many times, and more if the execution time variance is high.
--max-runs N
Maximum number of benchmark runs. Hyperfine will execute the commands at most this many times. Use with care as min-runs parameter will be ignored in case that max-runs parameter value has been met.
--runs N
Number of benchmark runs. Hyperfine will execute the commands exactly this many times.
--parameter-scan NAME FROM TO [STEP]
Scan command parameters over a range of values. Requires '--command' to contain '{NAME}'.
--parameter-list NAME VALUE1 VALUE2 ...
Run benchmarks with different parameters. Requires '--command' to contain '{NAME}'.
--prepare COMMAND
Command to run before each benchmark. Can be used to clean caches, etc.
--cleanup COMMAND
Command to run after all benchmarks are finished.
--export-json FILENAME
Export results to a JSON file.
--export-markdown FILENAME
Export results to a Markdown file.
--export-csv FILENAME
Export results to a CSV file.
--title TITLE
Set a title for the benchmark.
--shell SHELL
Shell to use for command execution (default: /bin/sh).
--ignore-failure
Ignore non-zero exit codes.
--show-output
Show the output of the command being benchmarked.
--time-unit auto|second|millisecond|microsecond|nanosecond
Choose the time unit in which to display the results
--style auto|basic|color|unicode
Select output style
--detect-outliers
Detect and exclude outlier runs from the results.
--affinity CPU-LIST
Bind command to specific CPU(s).
--setup COMMAND
Command to execute once before all benchmark runs.
--teardown COMMAND
Command to execute once after all benchmark runs.
--initial-value NUM
Sets the initial value for the parameter scan.
DESCRIPTION
hyperfine is a command-line benchmarking tool. It allows you to measure the execution time of shell commands and identify performance bottlenecks.
Unlike simple time commands, hyperfine automatically handles multiple runs and averages the results to provide more reliable measurements.
It supports warmup runs, customizable number of benchmark runs, command-line argument interpolation, shell execution, custom benchmark environments, statistical outlier detection, and exporting results in various formats like JSON, Markdown, and CSV. hyperfine is designed for reproducible benchmarks and provides helpful visualizations and statistical analysis to help compare command performances.
EXAMPLES
Basic Usage:
hyperfine 'sleep 1'
Comparing Commands:hyperfine 'sleep 1' 'sleep 0.5'
Using Parameter Scan:hyperfine --parameter-scan size 1 10 1 'echo {size}'
Ignoring errors:hyperfine --ignore-failure 'false'
SEE ALSO
time(1)