Skip to content
Myr

hyperfine.1

This file

Path

doc/hyperfine.1

371 lines · 10.5 KiB

Last changed by

Multiple output policiesDavid Peterbefore adoption99d24b7

History of this file

Take it

1.TH HYPERFINE 12.SH NAME3hyperfine \- command\-line benchmarking tool4.SH SYNOPSIS5.B hyperfine6.RB [ \-ihVN ]7.RB [ \-\-warmup8.IR NUM ]9.RB [ \-\-min\-runs10.IR NUM ]11.RB [ \-\-max\-runs12.IR NUM ]13.RB [ \-\-runs14.IR NUM ]15.RB [ \-\-setup16.IR CMD ]17.RB [ \-\-prepare18.IR CMD ]19.RB [ \-\-conclude20.IR CMD ]21.RB [ \-\-cleanup22.IR CMD ]23.RB [ \-\-parameter\-scan24.IR VAR25.IR MIN26.IR MAX ]27.RB [ \-\-parameter\-step\-size28.IR DELTA ]29.RB [ \-\-parameter\-list30.IR VAR31.IR VALUES ]32.RB [ \-\-shell33.IR SHELL ]34.RB [ \-\-style35.IR TYPE ]36.RB [ \-\-sort37.IR METHOD ]38.RB [ \-\-time-unit39.IR UNIT ]40.RB [ \-\-export\-asciidoc41.IR FILE ]42.RB [ \-\-export\-csv43.IR FILE ]44.RB [ \-\-export\-json45.IR FILE ]46.RB [ \-\-export\-markdown47.IR FILE ]48.RB [ \-\-export\-orgmode49.IR FILE ]50.RB [ \-\-output51.IR WHERE ]52.RB [ \-\-input53.IR WHERE ]54.RB [ \-\-command\-name55.IR NAME ]56.RI [ COMMAND... ]57.SH DESCRIPTION58A command\-line benchmarking tool which includes:59.LP60.RS61* Statistical analysis across multiple runs62.RE63.RS64* Support for arbitrary shell commands65.RE66.RS67* Constant feedback about the benchmark progress and current estimates68.RE69.RS70* Warmup runs can be executed before the actual benchmark71.RE72.RS73* Cache-clearing commands can be set up before each timing run74.RE75.RS76* Statistical outlier detection to detect interference from other programs and caching effects77.RE78.RS79* Export results to various formats: CSV, JSON, Markdown, AsciiDoc80.RE81.RS82* Parameterized benchmarks (e.g. vary the number of threads)83.RE84.SH OPTIONS85.HP86\fB\-w\fR, \fB\-\-warmup\fR \fINUM\fP87.IP88Perform \fINUM\fP warmup runs before the actual benchmark. This can be used89to fill (disk) caches for I/O\-heavy programs.90.HP91\fB\-m\fR, \fB\-\-min\-runs\fR \fINUM\fP92.IP93Perform at least \fINUM\fP runs for each command. Default: 10.94.HP95\fB\-M\fR, \fB\-\-max\-runs\fR \fINUM\fP96.IP97Perform at most \fINUM\fP runs for each command. By default, there is no98limit.99.HP100\fB\-r\fR, \fB\-\-runs\fR \fINUM\fP101.IP102Perform exactly \fINUM\fP runs for each command. If this option is not specified,103\fBhyperfine\fR automatically determines the number of runs.104.HP105\fB\-s\fR, \fB\-\-setup\fR \fICMD...\fP106.IP107Execute \fICMD\fP once before each set of timing runs. This is useful108for compiling your software or with the provided parameters, or to do any109other work that should happen once before a series of benchmark runs,110not every time as would happen with the \fB\-\-prepare\fR option.111.HP112\fB\-p\fR, \fB\-\-prepare\fR \fICMD...\fP113.IP114Execute \fICMD\fP before each timing run. This is useful for clearing disk caches,115for example.116The \fB\-\-prepare\fR option can be specified once for all commands or multiple times,117once for each command. In the latter case, each preparation command will be118run prior to the corresponding benchmark command.119.HP120.IP121Execute \fICMD\fP after each timing run. This is useful for clearing disk caches,122for example.123The \fB\-\-conclude\fR option can be specified once for all commands or multiple times,124once for each command. In the latter case, each conclusion command will be125run after the corresponding benchmark command.126.HP127\fB\-c\fR, \fB\-\-cleanup\fR \fICMD...\fP128.IP129Execute \fICMD\fP after the completion of all benchmarking runs for each individual130command to be benchmarked. This is useful if the commands to be benchmarked131produce artifacts that need to be cleaned up. It only runs once a series of132benchmark runs, as opposed to \fB\-\-conclude\fR option which runs after133ever run.134.HP135\fB\-P\fR, \fB\-\-parameter\-scan\fR \fIVAR\fP \fIMIN\fP \fIMAX\fP136.IP137Perform benchmark runs for each value in the range \fIMIN..MAX\fP. Replaces the138string '{\fIVAR\fP}' in each command by the current parameter value.139.IP140.RS141Example:142.RS143\fBhyperfine\fR \fB\-P\fR threads 1 8 'make \-j {threads}'144.RE145.RE146.IP147This performs benchmarks for 'make \-j 1', 'make \-j 2', ..., 'make \-j 8'.148.IP149To have the value increase following different patterns, use shell150arithmetics.151.IP152.RS153Example:154.RS155\fBhyperfine\fR \fB\-P\fR size 0 3 'sleep $((2**{size}))'156.RE157.RE158.IP159This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep1602', 'sleep 4', ...161.IP162The exact syntax may vary depending on your shell and OS.163.HP164\fB\-D\fR, \fB\-\-parameter\-step\-size\fR \fIDELTA\fP165.IP166This argument requires \fB\-\-parameter\-scan\fR to be specified as well. Traverse the167range \fIMIN..MAX\fP in steps of \fIDELTA\fP.168.IP169.RS170Example:171.RS172\fBhyperfine\fR \fB\-P\fR delay 0.3 0.7 \fB\-D\fR 0.2 'sleep {delay}'173.RE174.RE175.IP176This performs benchmarks for 'sleep 0.3', 'sleep 0.5' and 'sleep 0.7'.177.HP178\fB\-L\fR, \fB\-\-parameter\-list\fR \fIVAR\fP \fIVALUES\fP179.IP180Perform benchmark runs for each value in the comma\-separated list of \fIVALUES\fP.181Replaces the string '{\fIVAR\fP}' in each command by the current parameter value.182.IP183.RS184Example:185.RS186\fBhyperfine\fR \fB\-L\fR compiler gcc,clang '{compiler} \-O2 main.cpp'187.RE188.RE189.IP190This performs benchmarks for 'gcc \-O2 main.cpp' and 'clang \-O2 main.cpp'.191.IP192The option can be specified multiple times to run benchmarks for all193possible parameter combinations.194.HP195\fB\-S\fR, \fB\-\-shell\fR \fISHELL\fP196.IP197Set the shell to use for executing benchmarked commands. This can be198the name or the path to the shell executable, or a full command line199like "bash \fB\-\-norc\fR". It can also be set to "default" to explicitly200select the default shell on this platform. Finally, this can also be201set to "none" to disable the shell. In this case, commands will be202executed directly. They can still have arguments, but more complex203things like "sleep 0.1; sleep 0.2" are not possible without a shell.204.HP205\fB\-N\fR206.IP207An alias for '\-\-shell=none'.208.HP209\fB\-i\fR, \fB\-\-ignore\-failure\fR210.IP211Ignore non\-zero exit codes of the benchmarked programs.212.HP213\fB\-\-style\fR \fITYPE\fP214.IP215Set output style \fITYPE\fP (default: auto). Set this to 'basic' to disable output216coloring and interactive elements. Set it to 'full' to enable all effects even217if no interactive terminal was detected. Set this to 'nocolor' to keep the218interactive output without any colors. Set this to 'color' to keep the colors219without any interactive output. Set this to 'none' to disable all the output220of the tool.221.HP222\fB\-\-sort\fR \fIMETHOD\fP223.IP224Specify the sort order of the speed comparison summary and the225exported tables for markup formats (Markdown, AsciiDoc, org\-mode):226.RS227.IP "auto (default)"228the speed comparison will be ordered by time and229the markup tables will be ordered by command (input order).230.IP "command"231order benchmarks in the way they were specified232.IP "mean\-time"233order benchmarks by mean runtime234.RE235.HP236\fB\-u\fR, \fB\-\-time\-unit\fR \fIUNIT\fP237.IP238Set the time unit to be used. Possible values: microsecond, millisecond, second. If239the option is not given, the time unit is determined automatically.240This option affects the standard output as well as all export formats241except for CSV and JSON.242.HP243\fB\-\-export\-asciidoc\fR \fIFILE\fP 244.IP245Export the timing summary statistics as an AsciiDoc table to the given \fIFILE\fP.246The output time unit can be changed using the \fB\-\-time\-unit\fR option.247.HP248\fB\-\-export\-csv\fR \fIFILE\fP249.IP250Export the timing summary statistics as CSV to the given \fIFILE\fP. If you need the251timing results for each individual run, use the JSON export format.252The output time unit is always seconds.253.HP254\fB\-\-export\-json\fR \fIFILE\fP255.IP256Export the timing summary statistics and timings of individual runs as JSON to257the given \fIFILE\fP. The output time unit is always seconds.258.HP259\fB\-\-export\-markdown\fR \fIFILE\fP260.IP261Export the timing summary statistics as a Markdown table to the given \fIFILE\fP.262The output time unit can be changed using the \fB\-\-time\-unit\fR option.263.HP264\fB\-\-export\-orgmode\fR \fIFILE\fP265.IP266Export the timing summary statistics as an Emacs org\-mode table to the267given \fIFILE\fP. The output time unit can be changed using the \fB\-\-time\-unit\fR option.268.HP269\fB\-\-show\-output\fR270.IP271Print the stdout and stderr of the benchmark instead of suppressing it. This272will increase the time it takes for benchmarks to run, so it should only be273used for debugging purposes or when trying to benchmark output speed.274.HP275\fB\-\-output\fR \fIWHERE\fP276.IP277Control where the output of the benchmark is redirected. Note that278some programs like 'grep' detect when standard output is \fI\,/dev/null\/\fP and279apply certain optimizations. To avoid that, consider using280\-\-output=pipe.281.IP282\fIWHERE\fP can be:283.RS284.IP null285Redirect output to \fI\,/dev/null\/\fP (the default).286.IP pipe287Feed the output through a pipe before discarding it.288.IP inherit289Don't redirect the output at all (same as \&'\-\-show\-output').290.IP "<FILE>"291Write the output to the given file.292.RE293.IP294This option can be specified once for all commands or multiple times,295once for each command. Note: If you want to log the output of each and296every iteration, you can use a shell redirection and the $HYPERFINE_ITERATION297environment variable: 'my-command > output-${HYPERFINE_ITERATION}.log'298.HP299\fB\-\-input\fR \fIWHERE\fP300.IP301Control where the input of the benchmark comes from.302.IP303\fIWHERE\fP can be:304.RS305.IP null306Read from \fI\,/dev/null\/\fP (the default).307.IP "<FILE>"308Read the input from the given file.309.RE310.HP311\fB\-n\fR, \fB\-\-command\-name\fR \fiNAME\fP312.IP313Give a meaningful \fiNAME\fP to a command. This can be specified multiple times314if several commands are benchmarked.315.HP316\fB\-h\fR, \fB\-\-help\fR317.IP318Print help319.HP320\fB\-V\fR, \fB\-\-version\fR321.IP322Print version323.SH EXAMPLES324.LP325Basic benchmark of 'find . -name todo.txt':326.RS327.nf328\fBhyperfine\fR 'find . -name todo.txt'329.fi330.RE331.LP332Perform benchmarks for 'sleep 0.2' and 'sleep 3.2' with a minimum 5 runs each:333.RS334.nf335\fBhyperfine\fR \fB\-\-min\-runs\fR 5 'sleep 0.2' 'sleep 3.2'336.fi337.RE338.LP339Perform a benchmark of 'grep' with a warm disk cache by executing 3 runs up front that are not part340of the measurement: 341.RS342.nf343\fBhyperfine\fR \fB\-\-warmup\fR 3 'grep -R TODO *'344.fi345.RE346.LP347Export the results of a parameter scan benchmark to a markdown table: 348.RS349.nf350\fBhyperfine\fR \fB\-\-export\-markdown\fR output.md \fB\-\-parameter-scan\fR time 1 5 'sleep {time}'351.fi352.RE353.LP354Demonstrate when each of \fB\-\-setup\fR, \fB\-\-prepare\fR, \fB\-\-conclude\fR, \fIcmd\fP and \fB\-\-cleanup\fR will run:355.RS356.nf357\fBhyperfine\fR \fB\-L\fR n 1,2 \fB\-r\fR 2 \fB\-\-show-output\fR \\358	\fB\-\-setup\fR 'echo setup n={n}' \\359	\fB\-\-prepare\fR 'echo prepare={n}' \\360	\fB\-\-conclude\fR 'echo conclude={n}' \\361	\fB\-\-cleanup\fR 'echo cleanup n={n}' \\362	'echo command n={n}'363.fi364.RE365.RE366.SH AUTHOR367.LP368David Peter <mail@david-peter.de>369.LP370Source, bug tracker, and additional information can be found on GitHub:371.I https://github.com/sharkdp/hyperfine