Skip to content
Myr

README.md

This file

Path

README.md

355 lines · 10.9 KiB · Markdown

Last changed by

Update READMEDavid Peterbefore adoption92cc4f2

History of this file

Take it

The walk stopped after 200 commits: lines older than 790e1bf point at it.

Bump version to 1.15David Peterbefore adoption790e1bf

lines 1–12why, one step back
1# hyperfine
2[![CICD](https://github.com/sharkdp/hyperfine/actions/workflows/CICD.yml/badge.svg)](https://github.com/sharkdp/hyperfine/actions/workflows/CICD.yml)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)12

Update READMEDavid Peterbefore adoption92cc4f2

lines 13–24why, one step back
13### Sponsors
1415A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsor</a>:<br>1617<a href="https://www.warp.dev/hyperfine">18 <img src="doc/sponsors/warp-logo.png" width="200" alt="Warp">19 <br>20 <strong>Warp, the intelligent terminal</strong>21 <br>22 <sub>Available on MacOS, Linux, Windows</sub>23</a>24

Bump version to 1.15David Peterbefore adoption790e1bf

lines 25–42why, one step back
25## Features
2627* Statistical analysis across multiple runs.28* Support for arbitrary shell commands.29* Constant feedback about the benchmark progress and current estimates.30* Warmup runs can be executed before the actual benchmark.31* Cache-clearing commands can be set up before each timing run.32* Statistical outlier detection to detect interference from other programs and caching effects.33* Export results to various formats: CSV, JSON, Markdown, AsciiDoc.34* Parameterized benchmarks (e.g. vary the number of threads).35* Cross-platform3637## Usage3839### Basic benchmarks4041To run a benchmark, you can simply call `hyperfine <command>...`. The argument(s) can be any42shell command. For example:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 43why, one step back
43```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 44–49why, one step back
44hyperfine 'sleep 0.3'
45```4647Hyperfine will automatically determine the number of runs to perform for each command. By default,48it will perform *at least* 10 benchmarking runs and measure for at least 3 seconds. To change this,49you can use the `-r`/`--runs` option:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 50why, one step back
50```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 51–54why, one step back
51hyperfine --runs 5 'sleep 0.3'
52```5354If you want to compare the runtimes of different programs, you can pass multiple commands:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 55why, one step back
55```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 56–65why, one step back
56hyperfine 'hexdump file' 'xxd file'
57```5859### Warmup runs and preparation commands6061For programs that perform a lot of disk I/O, the benchmarking results can be heavily influenced62by disk caches and whether they are cold or warm.6364If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to65perform a certain number of program executions before the actual benchmark:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 66why, one step back
66```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 67–72why, one step back
67hyperfine --warmup 3 'grep -R TODO *'
68```6970Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`71option to run a special command before *each* timing run. For example, to clear harddisk caches72on Linux, you can run

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 73why, one step back
73```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 74–77why, one step back
74sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
75```76To use this specific command with hyperfine, call `sudo -v` to temporarily gain sudo permissions77and then call:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 78why, one step back
78```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 79–85why, one step back
79hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'
80```8182### Parameterized benchmarks8384If you want to run a series of benchmarks where a single parameter is varied (say, the number of85threads), you can use the `-P`/`--parameter-scan` option and call:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 86why, one step back
86```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 87–90why, one step back
87hyperfine --prepare 'make clean' --parameter-scan num_threads 1 12 'make -j {num_threads}'
88```89This also works with decimal numbers. The `-D`/`--parameter-step-size` option can be used90to control the step size:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 91why, one step back
91```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 92–105why, one step back
92hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'
93```94This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.9596For non-numeric parameters, you can also supply a list of values with the `-L`/`--parameter-list`97option:98```99hyperfine -L compiler gcc,clang '{compiler} -O2 main.cpp'100```101102### Intermediate shell103104By default, commands are executed using a predefined shell (`/bin/sh` on Unix, `cmd.exe` on Windows).105If you want to use a different shell, you can use the `-S, --shell <SHELL>` option:

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 106why, one step back
106```sh

Bump version to 1.15David Peterbefore adoption790e1bf

lines 107–116why, one step back
107hyperfine --shell zsh 'for i in {1..10000}; do echo test; done'
108```109110Note that hyperfine always *corrects for the shell spawning time*. To do this, it performs a calibration111procedure where it runs the shell with an empty command (multiple times), to measure the startup time112of the shell. It will then subtract this time from the total to show the actual time used by the command113in question.114115If you want to run a benchmark *without an intermediate shell*, you can use the `-N` or `--shell=none`116option. This is helpful for very fast commands (< 5 ms) where the shell startup overhead correction would

Fix a typoMateusz Piotrowskibefore adoption6c007ff

line 117why, one step back
117produce a significant amount of noise. Note that you cannot use shell syntax like `*` or `~` in this case.

Bump version to 1.15David Peterbefore adoption790e1bf

lines 118–124why, one step back
118```
119hyperfine -N 'grep TODO /home/user'120```121122123### Shell functions and aliases124

Revert to prev. sentenceDavid Peterbefore adoption69c91f5

line 125why, one step back
125If you are using bash, you can export shell functions to directly benchmark them with hyperfine:

Bump version to 1.15David Peterbefore adoption790e1bf

line 126why, one step back
126

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

lines 127–130why, one step back
127```bash
128my_function() { sleep 1; }129export -f my_function130hyperfine --shell=bash my_function

Bump version to 1.15David Peterbefore adoption790e1bf

lines 131–132why, one step back
131```
132

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 133why, one step back
133Otherwise, inline them into or source them from the benchmarked program:

Bump version to 1.15David Peterbefore adoption790e1bf

line 134why, one step back
134

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

lines 135–137why, one step back
135```sh
136hyperfine 'my_function() { sleep 1; }; my_function'137

Bump version to 1.15David Peterbefore adoption790e1bf

line 138why, one step back
138echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 139why, one step back
139hyperfine '. /tmp/my_alias.sh; my_alias'

Bump version to 1.15David Peterbefore adoption790e1bf

lines 140–146why, one step back
140```
141142### Exporting results143144Hyperfine has multiple options for exporting benchmark results to CSV, JSON, Markdown and other145formats (see `--help` text for details).146

Fix Shell functions and aliases sexion in READMEнабbefore adoption32e80fb

line 147why, one step back
147#### Markdown

Bump version to 1.15David Peterbefore adoption790e1bf

lines 148–177why, one step back
148
149You can use the `--export-markdown <file>` option to create tables like the following:150151| Command | Mean [s] | Min [s] | Max [s] | Relative |152|:---|---:|---:|---:|---:|153| `find . -iregex '.*[0-9]\.jpg$'` | 2.275 ± 0.046 | 2.243 | 2.397 | 9.79 ± 0.22 |154| `find . -iname '*[0-9].jpg'` | 1.427 ± 0.026 | 1.405 | 1.468 | 6.14 ± 0.13 |155| `fd -HI '.*[0-9]\.jpg$'` | 0.232 ± 0.002 | 0.230 | 0.236 | 1.00 |156157#### JSON158159The JSON output is useful if you want to analyze the benchmark results in more detail. The160[`scripts/`](https://github.com/sharkdp/hyperfine/tree/master/scripts) folder includes a lot161of helpful Python programs to further analyze benchmark results and create helpful162visualizations, like a histogram of runtimes or a whisker plot to compare163multiple benchmarks:164165| ![](doc/histogram.png) | ![](doc/whisker.png) |166|---:|---:|167168169### Detailed benchmark flowchart170171The following chart explains the execution order of various timing runs when using options172like `--warmup`, `--prepare <cmd>`, `--setup <cmd>` or `--cleanup <cmd>`:173174![](doc/execution-order.png)175176## Installation177

Update README.mdDavid Peterbefore adoption12fec42

line 178why, one step back
178[![Packaging status](https://repology.org/badge/vertical-allrepos/hyperfine.svg?columns=3&exclude_unsupported=1)](https://repology.org/project/hyperfine/versions)

Bump version to 1.15David Peterbefore adoption790e1bf

lines 179–184why, one step back
179
180### On Ubuntu181182Download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases)183and install it via `dpkg`:184```

Fix version in READMEDavid Peterbefore adoption87d77c8

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

Bump version to 1.15David Peterbefore adoption790e1bf

lines 187–205why, one step back
187```
188189### On Fedora190191On Fedora, hyperfine can be installed from the official repositories:192193```sh194dnf install hyperfine195```196197### On Alpine Linux198199On Alpine Linux, hyperfine can be installed [from the official repositories](https://pkgs.alpinelinux.org/packages?name=hyperfine):200```201apk add hyperfine202```203204### On Arch Linux205

Fix the Arch url to repo in README.mdAymenbefore adoptionc6a6dcc

line 206why, one step back
206On Arch Linux, hyperfine can be installed [from the official repositories](https://archlinux.org/packages/extra/x86_64/hyperfine/):

Bump version to 1.15David Peterbefore adoption790e1bf

lines 207–210why, one step back
207```
208pacman -S hyperfine209```210

Update README.mdbaarkerloungerbefore adoptione23b325

lines 211–212why, one step back
211### On Debian Linux
212

Fix typos README.mdAntonin Décimobefore adoption824aafb

line 213why, one step back
213On Debian Linux, hyperfine can be installed [from the testing repositories](https://packages.debian.org/testing/main/hyperfine):

Update README.mdbaarkerloungerbefore adoptione23b325

lines 214–217why, one step back
214```
215apt install hyperfine216```217

docs: add Exherbo Linux in README.md setup instructionsDavid Legrandbefore adoptiond712879

lines 218–219why, one step back
218### On Exherbo Linux
219

Fix typos README.mdAntonin Décimobefore adoption824aafb

line 220why, one step back
220On Exherbo Linux, hyperfine can be installed [from the rust repositories](https://gitlab.exherbo.org/exherbo/rust/-/tree/master/packages/sys-apps/hyperfine):

docs: add Exherbo Linux in README.md setup instructionsDavid Legrandbefore adoptiond712879

lines 221–225why, one step back
221```
222cave resolve -x repository/rust223cave resolve -x hyperfine224```225

Bump version to 1.15David Peterbefore adoption790e1bf

lines 226–239why, one step back
226### On Funtoo Linux
227228On Funtoo Linux, hyperfine can be installed [from core-kit](https://github.com/funtoo/core-kit/tree/1.4-release/app-benchmarks/hyperfine):229```230emerge app-benchmarks/hyperfine231```232233### On NixOS234235On NixOS, hyperfine can be installed [from the official repositories](https://nixos.org/nixos/packages.html?query=hyperfine):236```237nix-env -i hyperfine238```239

docs: Add flox installBryan Honofbefore adoption4a00f18

lines 240–247why, one step back
240### On Flox
241242On Flox, hyperfine can be installed as follows.243```244flox install hyperfine245```246Hyperfine's version in Flox follows that of Nix.247

Add openSUSE installation instructionsShun Sakaibefore adoption7696523

lines 248–254why, one step back
248### On openSUSE
249250On openSUSE, hyperfine can be installed [from the official repositories](https://software.opensuse.org/package/hyperfine):251```252zypper install hyperfine253```254

Bump version to 1.15David Peterbefore adoption790e1bf

lines 255–288why, one step back
255### On Void Linux
256257Hyperfine can be installed via xbps258259```260xbps-install -S hyperfine261```262263### On macOS264265Hyperfine can be installed via [Homebrew](https://brew.sh):266```267brew install hyperfine268```269270Or you can install using [MacPorts](https://www.macports.org):271```272sudo port selfupdate273sudo port install hyperfine274```275276### On FreeBSD277278Hyperfine can be installed via pkg:279```280pkg install hyperfine281```282283### On OpenBSD284285```286doas pkg_add hyperfine287```288

Add Windows installation instructionssitiombefore adoption36d6155

lines 289–301why, one step back
289### On Windows
290291Hyperfine can be installed via [Chocolatey](https://community.chocolatey.org/packages/hyperfine), [Scoop](https://scoop.sh/#/apps?q=hyperfine&s=0&d=1&o=true&id=8f7c10f75ecf5f9e42a862c615257328e2f70f61), or [Winget](https://github.com/microsoft/winget-pkgs/tree/master/manifests/s/sharkdp/hyperfine):292```293choco install hyperfine294```295```296scoop install hyperfine297```298```299winget install hyperfine300```301

Bump version to 1.15David Peterbefore adoption790e1bf

lines 302–312why, one step back
302### With conda
303304Hyperfine can be installed via [`conda`](https://conda.io/en/latest/) from the [`conda-forge`](https://anaconda.org/conda-forge/hyperfine) channel:305```306conda install -c conda-forge hyperfine307```308309### With cargo (Linux, macOS, Windows)310311Hyperfine can be installed from source via [cargo](https://doc.rust-lang.org/cargo/):312```

Suggest to use `cargo install --locked`, see #605 andDavid Peterbefore adoptionc4b54b0

line 313why, one step back
313cargo install --locked hyperfine

Bump version to 1.15David Peterbefore adoption790e1bf

lines 314–315why, one step back
314```
315

Update dependenciesDavid Peterbefore adoption2efc633

line 316why, one step back
316Make sure that you use Rust 1.76 or newer.

Bump version to 1.15David Peterbefore adoption790e1bf

lines 317–323why, one step back
317
318### From binaries (Linux, macOS, Windows)319320Download the corresponding archive from the [Release page](https://github.com/sharkdp/hyperfine/releases).321322## Alternative tools323

Fix a link to benchMateusz Piotrowskibefore adoption4c993b5

line 324why, one step back
324Hyperfine is inspired by [bench](https://github.com/Gabriella439/bench).

Bump version to 1.15David Peterbefore adoption790e1bf

lines 325–330why, one step back
325
326## Integration with other tools327328[Chronologer](https://github.com/dandavison/chronologer) is a tool that uses `hyperfine` to329visualize changes in benchmark timings across your Git history.330

Add Bencher to list of toolsEverett Pompeiibefore adoptionc5089d8

lines 331–333why, one step back
331[Bencher](https://github.com/bencherdev/bencher) is a continuous benchmarking tool that supports `hyperfine` to
332track benchmarks and catch performance regressions in CI.333

Add link to VenzLars Kappertbefore adoption3b09185

lines 334–336why, one step back
334Drop hyperfine JSON outputs onto the [Venz](https://try.venz.dev) chart to visualize the results,
335and manage hyperfine configurations.336

Bump version to 1.15David Peterbefore adoption790e1bf

lines 337–345why, one step back
337Make sure to check out the [`scripts` folder](https://github.com/sharkdp/hyperfine/tree/master/scripts)
338in this repository for a set of tools to work with `hyperfine` benchmark results.339340## Origin of the name341342The name *hyperfine* was chosen in reference to the hyperfine levels of caesium 133 which play a crucial role in the343[definition of our base unit of time](https://en.wikipedia.org/wiki/Second#History_of_definition)344— the second.345

Add citing guide, as per issue #566wrenbefore adoption64f26d2

lines 346–347why, one step back
346## Citing hyperfine
347

Move information to CITATION.cff fileDavid Peterbefore adoption779d425

lines 348–349why, one step back
348Thank you for considering to cite hyperfine in your research work. Please see the information
349in the sidebar on how to properly cite hyperfine.

Add citing guide, as per issue #566wrenbefore adoption64f26d2

line 350why, one step back
350

Bump version to 1.15David Peterbefore adoption790e1bf

lines 351–355why, one step back
351## License
352353`hyperfine` is dual-licensed under the terms of the MIT License and the Apache License 2.0.354355See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for details.