Skip to content
Myr

README.md

This file

Path

README.md

239 lines · 7.4 KiB · Markdown

Last changed by

Fix clippy suggestionsDavid Peterbefore adoptionf5de548

History of this file

Take it

The walk stopped after 200 commits: lines older than 699d8ca point at it.

Add ARM binariesDavid Peterbefore adoption699d8ca

line 1why, one step back
1# hyperfine

Update README.mdDavid Peterbefore adoptiona044532

line 2why, one step back
2[![CICD](https://github.com/sharkdp/hyperfine/actions/workflows/CICD.yml/badge.svg)](https://github.com/sharkdp/hyperfine/actions/workflows/CICD.yml)

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 3–77why, one step back
3[![Version info](https://img.shields.io/crates/v/hyperfine.svg)](https://crates.io/crates/hyperfine)
4[中文](https://github.com/chinanf-boy/hyperfine-zh)56A command-line benchmarking tool.78**Demo**: Benchmarking [`fd`](https://github.com/sharkdp/fd) and9[`find`](https://www.gnu.org/software/findutils/):1011![hyperfine](https://i.imgur.com/z19OYxE.gif)1213## Features1415* Statistical analysis across multiple runs.16* Support for arbitrary shell commands.17* Constant feedback about the benchmark progress and current estimates.18* Warmup runs can be executed before the actual benchmark.19* Cache-clearing commands can be set up before each timing run.20* Statistical outlier detection to detect interference from other programs and caching effects.21* Export results to various formats: CSV, JSON, Markdown, AsciiDoc.22* Parameterized benchmarks (e.g. vary the number of threads).23* Cross-platform2425## Usage2627### Basic benchmark2829To run a benchmark, you can simply call `hyperfine <command>...`. The argument(s) can be any30shell command. For example:31``` bash32hyperfine 'sleep 0.3'33```3435Hyperfine will automatically determine the number of runs to perform for each command. By default,36it will perform *at least* 10 benchmarking runs. To change this, you can use the `-m`/`--min-runs`37option:38``` bash39hyperfine --min-runs 5 'sleep 0.2' 'sleep 3.2'40```4142### Warmup runs and preparation commands4344If the program execution time is limited by disk I/O, the benchmarking results can be heavily45influenced by disk caches and whether they are cold or warm.4647If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to perform48a certain number of program executions before the actual benchmark:49``` bash50hyperfine --warmup 3 'grep -R TODO *'51```5253Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`54option to run a special command before *each* timing run. For example, to clear harddisk caches55on Linux, you can run56``` bash57sync; echo 3 | sudo tee /proc/sys/vm/drop_caches58```59To use this specific command with Hyperfine, call `sudo -v` to temporarily gain sudo permissions60and then call:61``` bash62hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'63```6465### Parameterized benchmarks6667If you want to run a benchmark where only a single parameter is varied (say, the number of68threads), you can use the `-P`/`--parameter-scan` option and call:69``` bash70hyperfine --prepare 'make clean' --parameter-scan num_threads 1 12 'make -j {num_threads}'71```72This also works with decimal numbers. The `-D`/`--parameter-step-size` option can be used73to control the step size:74``` bash75hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'76```77This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.

Incorporate suggestions from reviewThiago Arraisbefore adoption8704e76

lines 78–97why, one step back
78
79### Shell functions and aliases8081If you are using bash, you can export shell functions to directly benchmark them with hyperfine:8283```84$ my_function() { sleep 1; }85$ export -f my_function86$ hyperfine my_function87```8889If you are using a different shell, or if you want to benchmark shell aliases, you may try to put90them in a separate file:9192```bash93echo 'my_function() { sleep 1 }' > /tmp/my_function.sh94echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh95hyperfine 'source /tmp/my_function.sh; eval my_function'96hyperfine 'source /tmp/my_alias.sh; eval my_alias'97```

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 98–122why, one step back
98
99### Export results100101Hyperfine has multiple options for exporting benchmark results: CSV, JSON, Markdown (see `--help`102text for details). To export results to Markdown, for example, you can use the `--export-markdown`103option that will create tables like this:104105| Command | Mean [s] | Min [s] | Max [s] | Relative |106|:---|---:|---:|---:|---:|107| `find . -iregex '.*[0-9]\.jpg$'` | 2.275 ± 0.046 | 2.243 | 2.397 | 9.79 ± 0.22 |108| `find . -iname '*[0-9].jpg'` | 1.427 ± 0.026 | 1.405 | 1.468 | 6.14 ± 0.13 |109| `fd -HI '.*[0-9]\.jpg$'` | 0.232 ± 0.002 | 0.230 | 0.236 | 1.00 |110111The JSON output is useful if you want to analyze the benchmark results in more detail. See the112[`scripts/`](https://github.com/sharkdp/hyperfine/tree/master/scripts) folder for some examples.113114## Installation115116[![Packaging status](https://repology.org/badge/vertical-allrepos/hyperfine.svg)](https://repology.org/project/hyperfine/versions)117118### On Ubuntu119120Download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases)121and install it via `dpkg`:122```

Prepare release v1.12David Peterbefore adoption93c1653

lines 123–124why, one step back
123wget https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_amd64.deb
124sudo dpkg -i hyperfine_1.12.0_amd64.deb

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 125–148why, one step back
125```
126127### On Fedora128129On Fedora, hyperfine can be installed from the official repositories:130131```sh132dnf install hyperfine133```134135### On Alpine Linux136137On Alpine Linux, hyperfine can be installed [from the official repositories](https://pkgs.alpinelinux.org/packages?name=hyperfine):138```139apk add hyperfine140```141142### On Arch Linux143144On Arch Linux, hyperfine can be installed [from the official repositories](https://www.archlinux.org/packages/community/x86_64/hyperfine/):145```146pacman -S hyperfine147```148

chore: add funtoo linux instructionsinvakid404before adoptionf5db783

lines 149–155why, one step back
149### On Funtoo Linux
150151On Funtoo Linux, hyperfine can be installed [from core-kit](https://github.com/funtoo/core-kit/tree/1.4-release/app-benchmarks/hyperfine):152```153emerge app-benchmarks/hyperfine154```155

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 156–205why, one step back
156### On NixOS
157158On NixOS, hyperfine can be installed [from the official repositories](https://nixos.org/nixos/packages.html?query=hyperfine):159```160nix-env -i hyperfine161```162163### On Void Linux164165Hyperfine can be installed via xbps166167```168xbps-install -S hyperfine169```170171### On macOS172173Hyperfine can be installed via [Homebrew](https://brew.sh):174```175brew install hyperfine176```177178Or you can install using [MacPorts](https://www.macports.org):179```180sudo port selfupdate181sudo port install hyperfine182```183184### On FreeBSD185186Hyperfine can be installed via pkg:187```188pkg install hyperfine189```190191### On OpenBSD192193```194doas pkg_add hyperfine195```196197### With conda198199Hyperfine can be installed via [`conda`](https://conda.io/en/latest/) from the [`conda-forge`](https://anaconda.org/conda-forge/hyperfine) channel:200```201conda install -c conda-forge hyperfine202```203204### With cargo (Linux, macOS, Windows)205

Update install instructionsDavid Peterbefore adoptionf443195

line 206why, one step back
206Hyperfine can be installed from source via [cargo](https://doc.rust-lang.org/cargo/):

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 207–210why, one step back
207```
208cargo install hyperfine209```210

Fix clippy suggestionsDavid Peterbefore adoptionf5de548

line 211why, one step back
211Make sure that you use Rust 1.57 or higher.

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 212–219why, one step back
212
213### From binaries (Linux, macOS, Windows)214215Download the corresponding archive from the [Release page](https://github.com/sharkdp/hyperfine/releases).216217## Alternative tools218219Hyperfine is inspired by [bench](https://github.com/Gabriel439/bench).

Bump version to 1.11.0sharkdpbefore adoption118baa9

line 220why, one step back
220

Add ARM binariesDavid Peterbefore adoption699d8ca

lines 221–236why, one step back
221## Integration with other tools
222223[Chronologer](https://github.com/dandavison/chronologer) is a tool that uses `hyperfine` to224visualize changes in benchmark timings across your Git history.225226Make sure to check out the [`scripts` folder](https://github.com/sharkdp/hyperfine/tree/master/scripts)227in this repository for a set of tools to work with `hyperfine` benchmark results.228229## Origin of the name230231The name *hyperfine* was chosen in reference to the hyperfine levels of caesium 133 which play a crucial role in the232[definition of our base unit of time](https://en.wikipedia.org/wiki/Second#History_of_definition)233— the second.234235## License236

Remove years from copyright noticeDavid Peterbefore adoptionb5bd054

line 237why, one step back
237`hyperfine` is dual-licensed under the terms of the MIT License and the Apache License 2.0.

Add ARM binariesDavid Peterbefore adoption699d8ca

line 238why, one step back
238

Remove years from copyright noticeDavid Peterbefore adoptionb5bd054

line 239why, one step back
239See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for details.