Update documentation
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by GitHub · parent 5c676a9 · Browse files · 1 file·+42 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+42 added−10 removed
- other:+42 added−10 removed
Provenance
- Commit
851e9b8- Tree
94ef3f6- Author
David Peter <sharkdp@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
5c676a9
1 file changed+42 added−10 removed
modified:README.md+42 added-10 removed
22 unmodified lines23 * Cross-platform24 25 ## Usage26 27-### Basic benchmark27+### Basic benchmarks28 29 To run a benchmark, you can simply call `hyperfine <command>...`. The argument(s) can be any30 shell command. For example:31 ``` bash32 hyperfine 'sleep 0.3'33 ```34 35 Hyperfine will automatically determine the number of runs to perform for each command. By default,36-it will perform *at least* 10 benchmarking runs. To change this, you can use the `-m`/`--min-runs`37-option:36+it will perform *at least* 10 benchmarking runs and measure for at least 3 seconds. To change this,37+you can use the `-r`/`--runs` option:38 ``` bash39-hyperfine --min-runs 5 'sleep 0.2' 'sleep 3.2'39+hyperfine --runs 5 'sleep 0.3'40 ```41 42+If you want to compare the runtimes of different programs, you can pass multiple commands:43+``` bash44+hyperfine 'hexdump file' 'xxd file'45+```46+47 ### Warmup runs and preparation commands48 44-If the program execution time is limited by disk I/O, the benchmarking results can be heavily45-influenced by disk caches and whether they are cold or warm.49+For programs that perform a lot of disk I/O, the benchmarking results can be heavily influenced50+by disk caches and whether they are cold or warm.51 47-If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to perform48-a certain number of program executions before the actual benchmark:52+If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to53+perform a certain number of program executions before the actual benchmark:54 ``` bash55 hyperfine --warmup 3 'grep -R TODO *'56 ```57 2 unmodified lines60 on Linux, you can run61 ``` bash62 sync; echo 3 | sudo tee /proc/sys/vm/drop_caches63 ```59-To use this specific command with Hyperfine, call `sudo -v` to temporarily gain sudo permissions64+To use this specific command with hyperfine, call `sudo -v` to temporarily gain sudo permissions65 and then call:66 ``` bash67 hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'68 ```69 70 ### Parameterized benchmarks71 67-If you want to run a benchmark where only a single parameter is varied (say, the number of72+If you want to run a series of benchmarks where a single parameter is varied (say, the number of73 threads), you can use the `-P`/`--parameter-scan` option and call:74 ``` bash75 hyperfine --prepare 'make clean' --parameter-scan num_threads 1 12 'make -j {num_threads}'76 ```3 unmodified lines80 hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'81 ```82 This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.83 84+For non-numeric parameters, you can also supply a list of values with the `-L`/`--parameter-list`85+option:86+```87+hyperfine -L compiler gcc,clang '{compiler} -O2 main.cpp'88+```89+90+### Intermediate shell91+92+By default, commands are executed using a predefined shell (`/bin/sh` on Unix, `cmd.exe` on Windows).93+If you want to use a different shell, you can use the `-S, --shell <SHELL>` option:94+``` bash95+hyperfine --shell zsh 'for i in {1..10000}; do echo test; done'96+```97+98+Note that hyperfine always *corrects for the shell spawning time*. To do this, it performs a calibration99+procedure where it runs the shell with an empty command (multiple times), to measure the startup time100+of the shell. It will then subtract this time from the total to show the actual time used by the command101+in question.102+103+If you want to run a benchmark *without an intermediate shell*, you can use the `-N` or `--shell=none`104+option. This is helpful for very fast commands (< 5 ms) where the shell startup overhead correction would105+produce a significant amount of noise. Note that you can not use shell syntax like `*` or `~` in this case.106+```107+hyperfine -N 'grep TODO /home/user'108+```109+110+111 ### Shell functions and aliases112 113 If you are using bash, you can export shell functions to directly benchmark them with hyperfine:114 157 unmodified lines