Skip to content
Myr

README.md

This file

Path

README.md

233 lines · 7.2 KiB · Markdown

Last changed by

Update README.mdDavid Peterbefore adoptiona044532

History of this file

Take it

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

update output condition check to use .mapknidarknessbefore adoptionb3084cb

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)

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 3–10why, 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/):10

Update demo GIFDavid Peterbefore adoption72f113e

line 11why, one step back
11![hyperfine](https://i.imgur.com/z19OYxE.gif)

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 12–77why, one step back
12
13## 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```

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 98–115why, 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## Installation115

Add packaging statusDavid Peterbefore adoptionf3f623e

lines 116–117why, one step back
116[![Packaging status](https://repology.org/badge/vertical-allrepos/hyperfine.svg)](https://repology.org/project/hyperfine/versions)
117

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 118–122why, one step back
118### On Ubuntu
119120Download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases)121and install it via `dpkg`:122```

Bump version to 1.11.0sharkdpbefore adoption118baa9

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

update output condition check to use .mapknidarknessbefore adoptionb3084cb

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

Add NixOS instructionsDenny Schäferbefore adoption73b3eaa

lines 149–155why, one step back
149### On NixOS
150151On NixOS, hyperfine can be installed [from the official repositories](https://nixos.org/nixos/packages.html?query=hyperfine):152```153nix-env -i hyperfine154```155

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 156–170why, one step back
156### On Void Linux
157158Hyperfine can be installed via xbps159160```161xbps-install -S hyperfine162```163164### On macOS165166Hyperfine can be installed via [Homebrew](https://brew.sh):167```168brew install hyperfine169```170

README: add instructions on installing via MacPorts for macOSHerby Gillotbefore adoptiona7e2889

lines 171–176why, one step back
171Or you can install using [MacPorts](https://www.macports.org):
172```173sudo port selfupdate174sudo port install hyperfine175```176

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 177–183why, one step back
177### On FreeBSD
178179Hyperfine can be installed via pkg:180```181pkg install hyperfine182```183

there is now an openbsd port for hyperfineFrantisek Holopbefore adoption7236531

lines 184–189why, one step back
184### On OpenBSD
185186```187doas pkg_add hyperfine188```189

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 190–203why, one step back
190### With conda
191192Hyperfine can be installed via [`conda`](https://conda.io/en/latest/) from the [`conda-forge`](https://anaconda.org/conda-forge/hyperfine) channel:193```194conda install -c conda-forge hyperfine195```196197### With cargo (Linux, macOS, Windows)198199Hyperfine can be installed via [cargo](https://doc.rust-lang.org/cargo/):200```201cargo install hyperfine202```203

Update dependenciesDavid Peterbefore adoption57850d4

line 204why, one step back
204Make sure that you use Rust 1.46 or higher.

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 205–211why, one step back
205
206### From binaries (Linux, macOS, Windows)207208Download the corresponding archive from the [Release page](https://github.com/sharkdp/hyperfine/releases).209210## Alternative tools211

Add link to chronologerDavid Peterbefore adoption92bab7e

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

Bump version to 1.11.0sharkdpbefore adoption118baa9

line 213why, one step back
213

Add link to chronologerDavid Peterbefore adoption92bab7e

lines 214–220why, one step back
214## Integration with other tools
215216[Chronologer](https://github.com/dandavison/chronologer) is a tool that uses `hyperfine` to217visualize changes in benchmark timings across your Git history.218219Make sure to check out the [`scripts` folder](https://github.com/sharkdp/hyperfine/tree/master/scripts)220in this repository for a set of tools to work with `hyperfine` benchmark results.

update output condition check to use .mapknidarknessbefore adoptionb3084cb

lines 221–226why, one step back
221
222## Origin of the name223224The name *hyperfine* was chosen in reference to the hyperfine levels of caesium 133 which play a crucial role in the225[definition of our base unit of time](https://en.wikipedia.org/wiki/Second#History_of_definition)226— the second.

Fix LICENSEShun Sakaibefore adoption880246c

lines 227–233why, one step back
227
228## License229Copyright (c) 2018-2020 The hyperfine developers230231`hyperfine` is distributed under the terms of both the MIT License and the Apache License 2.0.232233See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for license details.