TIL: Benchmarking Commands With hyperfine
A script that runs in 2 seconds feels fast. A benchmark tells you whether it actually is and how consistent it stays.
hyperfine 'node sdk.js' 'python sdk.py'
Runs each command multiple times and reports mean, min, max, and standard deviation. The second or two of warmup runs are excluded from the results.
hyperfine --warmup 3 'node sdk.js'
Run three warmup iterations before measuring. Cold starts skew results.
hyperfine --export-markdown bench.md 'node sdk.js' 'python sdk.py'
Export results as a markdown table. Paste it directly into a PR or documentation.
Does hyperfine handle shell commands?
Yes. Commands are passed to the shell. Pipes, redirects, and subshells all work.
How do I install hyperfine?
brew install hyperfine