Skip to content
Myr

Incorporate suggestions from review

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Thiago Arrais · committed by David Peter · parent e1fea57 · Browse files · 1 file+20 added−20 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+20 added−20 removed

  • other:+20 added−20 removed

1 file+20 added−20 removed

modified:README.md+20 added-20 removed
38 unmodified lines
39``` bash40hyperfine --min-runs 5 'sleep 0.2' 'sleep 3.2'41```4243### Tip: aliases and functions4445Aliases and shell functions can't be benchmarked directly, but you may try to put them in a separate46file and benchmark _that_:4748```bash49echo 'my_function() { sleep 1 }' > /tmp/my_function.sh50echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh51hyperfine 'source /tmp/my_function.sh; eval my_function'52hyperfine 'source /tmp/my_alias.sh; eval my_alias'53```5455If you're using bash, you may also want to `export` functions (can't do that with aliases, though):5657```58$ my_function() { sleep 1; }59$ export -f my_function60$ hyperfine my_function61```6243### Warmup runs and preparation commands4445If the program execution time is limited by disk I/O, the benchmarking results can be heavily46influenced by disk caches and whether they are cold or warm.
29 unmodified lines
76hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'77```78This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.7980### Shell functions and aliases8182If you are using bash, you can export shell functions to directly benchmark them with hyperfine:8384```85$ my_function() { sleep 1; }86$ export -f my_function87$ hyperfine my_function88```8990If you are using a different shell, or if you want to benchmark shell aliases, you may try to put91them in a separate file:9293```bash94echo 'my_function() { sleep 1 }' > /tmp/my_function.sh95echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh96hyperfine 'source /tmp/my_function.sh; eval my_function'97hyperfine 'source /tmp/my_alias.sh; eval my_alias'98```99100### Export results101102Hyperfine has multiple options for exporting benchmark results: CSV, JSON, Markdown (see `--help`103text for details). To export results to Markdown, for example, you can use the `--export-markdown`
131 unmodified lines