# hyperfine
> A command-line benchmarking tool with statistical analysis

## Summary
A command-line benchmarking tool with statistical analysis. Runs commands multiple times, performs warmup runs, detects outliers, and supports comparative benchmarking.

## Capabilities
- Statistical analysis with mean, stddev, min, max
- Warmup runs and cache clearing between runs
- Side-by-side comparison of multiple commands
- Export results as JSON, CSV, or Markdown

## When to Use
- Benchmarking CLI commands or scripts
- Comparing performance of alternative tools or approaches
- Need statistically rigorous timing measurements

## When NOT to Use
- Profiling code internals (use a language-specific profiler)
- One-off timing where shell 'time' suffices

## Key Flags
- `--warmup`: Number of warmup runs before actual benchmarking (e.g. --warmup 3)
- `--min-runs`: Minimum number of benchmark runs (default: 10)
- `--prepare`: Command to run before each benchmark run (e.g. cache clearing)
- `--export-json`: Export results as JSON for further analysis
- `--shell`: Set the shell to use for executing benchmarked commands

## Usage Patterns
### Benchmark a single command
```
hyperfine 'fd -e py'
```
Runs the command multiple times and shows statistical summary

### Compare two commands
```
hyperfine 'find . -name "*.py"' 'fd -e py'
```
Benchmarks both commands and shows relative performance

## Input / Output
- **stdout**: Statistical summary with timing results

## Installation
- **homebrew**: `brew install hyperfine`
- **cargo**: `cargo install hyperfine`
- **apt**: `sudo apt install hyperfine`
- **pacman**: `sudo pacman -S hyperfine`

---
Source: https://littlescripts.sh/tools/hyperfine
