hyperfine.1
This file
Path
doc/hyperfine.1
403 lines · 11.5 KiB
Last changed by
Merge pull request #951 from Likio3000/codex/reject-negative-parameter-stepsDavid Peterbefore adoption862625f
History of this fileTake it
1.TH HYPERFINE 12.SH NAME3hyperfine \- command\-line benchmarking tool4.SH SYNOPSIS5.B hyperfine6.RB [ \-hVN ]7.RB [ \-\-ignore\-failure[=MODE] ]8.RB [ \-\-warmup9.IR NUM ]10.RB [ \-\-min\-runs11.IR NUM ]12.RB [ \-\-max\-runs13.IR NUM ]14.RB [ \-\-runs15.IR NUM ]16.RB [ \-\-setup17.IR CMD ]18.RB [ \-\-reference19.IR CMD ]20.RB [ \-\-reference\-name21.IR NAME ]22.RB [ \-\-prepare23.IR CMD ]24.RB [ \-\-conclude25.IR CMD ]26.RB [ \-\-cleanup27.IR CMD ]28.RB [ \-\-parameter\-scan29.IR VAR30.IR MIN31.IR MAX ]32.RB [ \-\-parameter\-step\-size33.IR DELTA ]34.RB [ \-\-parameter\-list35.IR VAR36.IR VALUES ]37.RB [ \-\-shell38.IR SHELL ]39.RB [ \-\-style40.IR TYPE ]41.RB [ \-\-sort42.IR METHOD ]43.RB [ \-\-time-unit44.IR UNIT ]45.RB [ \-\-export\-asciidoc46.IR FILE ]47.RB [ \-\-export\-csv48.IR FILE ]49.RB [ \-\-export\-json50.IR FILE ]51.RB [ \-\-export\-markdown52.IR FILE ]53.RB [ \-\-export\-orgmode54.IR FILE ]55.RB [ \-\-output56.IR WHERE ]57.RB [ \-\-input58.IR WHERE ]59.RB [ \-\-command\-name60.IR NAME ]61.RI [ COMMAND... ]62.SH DESCRIPTION63A command\-line benchmarking tool which includes:64.LP65.RS66* Statistical analysis across multiple runs67.RE68.RS69* Support for arbitrary shell commands70.RE71.RS72* Constant feedback about the benchmark progress and current estimates73.RE74.RS75* Warmup runs can be executed before the actual benchmark76.RE77.RS78* Cache-clearing commands can be set up before each timing run79.RE80.RS81* Statistical outlier detection to detect interference from other programs and caching effects82.RE83.RS84* Export results to various formats: CSV, JSON, Markdown, AsciiDoc85.RE86.RS87* Parameterized benchmarks (e.g. vary the number of threads)88.RE89.SH OPTIONS90.HP91\fB\-w\fR, \fB\-\-warmup\fR \fINUM\fP92.IP93Perform \fINUM\fP warmup runs before the actual benchmark. This can be used94to fill (disk) caches for I/O\-heavy programs.95.HP96\fB\-m\fR, \fB\-\-min\-runs\fR \fINUM\fP97.IP98Perform at least \fINUM\fP runs for each command. Default: 10.99.HP100\fB\-M\fR, \fB\-\-max\-runs\fR \fINUM\fP101.IP102Perform at most \fINUM\fP runs for each command. By default, there is no103limit.104.HP105\fB\-r\fR, \fB\-\-runs\fR \fINUM\fP106.IP107Perform exactly \fINUM\fP runs for each command. If this option is not specified,108\fBhyperfine\fR automatically determines the number of runs.109.HP110\fB\-s\fR, \fB\-\-setup\fR \fICMD...\fP111.IP112Execute \fICMD\fP once before each set of timing runs. This is useful113for compiling your software with the provided parameters, or to do any114other work that should happen once before a series of benchmark runs,115not every time as would happen with the \fB\-\-prepare\fR option.116.HP117\fB\-\-reference\fR \fICMD\fP118.IP119Benchmark \fICMD\fP as the reference for the relative comparison of results.120If this option is not specified, the fastest command is used as the reference.121.HP122\fB\-\-reference\-name\fR \fINAME\fP123.IP124Give a meaningful \fINAME\fP to the reference command.125Requires \fB\-\-reference\fR.126.HP127\fB\-p\fR, \fB\-\-prepare\fR \fICMD...\fP128.IP129Execute \fICMD\fP before each timing run. This is useful for clearing disk caches,130for example.131The \fB\-\-prepare\fR option can be specified once for all commands or multiple times,132once for each command. In the latter case, each preparation command will be133run prior to the corresponding benchmark command.134.HP135\fB\-C\fR, \fB\-\-conclude\fR \fICMD...\fP136.IP137Execute \fICMD\fP after each timing run. This is useful for clearing disk caches,138for example.139The \fB\-\-conclude\fR option can be specified once for all commands or multiple times,140once for each command. In the latter case, each conclusion command will be141run after the corresponding benchmark command.142.HP143\fB\-c\fR, \fB\-\-cleanup\fR \fICMD...\fP144.IP145Execute \fICMD\fP after the completion of all benchmarking runs for each individual146command to be benchmarked. This is useful if the commands to be benchmarked147produce artifacts that need to be cleaned up. It only runs once per series of148benchmark runs, as opposed to the \fB\-\-conclude\fR option which runs after149every run.150.HP151\fB\-P\fR, \fB\-\-parameter\-scan\fR \fIVAR\fP \fIMIN\fP \fIMAX\fP152.IP153Perform benchmark runs for each value in the range \fIMIN..MAX\fP. Replaces the154string '{\fIVAR\fP}' in each command by the current parameter value.155.IP156.RS157Example:158.RS159\fBhyperfine\fR \fB\-\-prepare\fR 'make clean' \fB\-P\fR threads 1 8 'make \-j {threads}'160.RE161.RE162.IP163This performs benchmarks for 'make \-j 1', 'make \-j 2', ..., 'make \-j 8'.164.IP165To have the value increase following different patterns, use shell166arithmetic.167.IP168.RS169Example:170.RS171\fBhyperfine\fR \fB\-P\fR size 0 3 'sleep $((2**{size}))'172.RE173.RE174.IP175This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep1762', 'sleep 4', ...177.IP178The exact syntax may vary depending on your shell and OS.179.HP180\fB\-D\fR, \fB\-\-parameter\-step\-size\fR \fIDELTA\fP181.IP182This argument requires \fB\-\-parameter\-scan\fR to be specified as well. Traverse the183range \fIMIN..MAX\fP in steps of \fIDELTA\fP, which must be positive.184.IP185.RS186Example:187.RS188\fBhyperfine\fR \fB\-P\fR delay 0.3 0.7 \fB\-D\fR 0.2 'sleep {delay}'189.RE190.RE191.IP192This performs benchmarks for 'sleep 0.3', 'sleep 0.5' and 'sleep 0.7'.193.HP194\fB\-L\fR, \fB\-\-parameter\-list\fR \fIVAR\fP \fIVALUES\fP195.IP196Perform benchmark runs for each value in the comma\-separated list of \fIVALUES\fP.197Replaces the string '{\fIVAR\fP}' in each command by the current parameter value.198.IP199.RS200Example:201.RS202\fBhyperfine\fR \fB\-L\fR compiler g++,clang++ '{compiler} \-O2 main.cpp'203.RE204.RE205.IP206This performs benchmarks for 'g++ \-O2 main.cpp' and 'clang++ \-O2 main.cpp'.207.IP208The option can be specified multiple times to run benchmarks for all209possible parameter combinations.210.HP211\fB\-S\fR, \fB\-\-shell\fR \fISHELL\fP212.IP213Set the shell to use for executing benchmarked commands. This can be214the name or the path to the shell executable, or a full command line215like "bash \fB\-\-norc\fR". It can also be set to "default" to explicitly216select the default shell on this platform. Finally, this can also be217set to "none" to disable the shell. In this case, commands will be218executed directly. They can still have arguments, but more complex219things like "sleep 0.1; sleep 0.2" are not possible without a shell.220.HP221\fB\-N\fR222.IP223An alias for '\-\-shell=none'.224.HP225\fB\-i\fR, \fB\-\-ignore\-failure\fR[=\fIMODE\fP]226.IP227Ignore failures of the benchmarked programs. Without a value or with228\fBall\-non\-zero\fR, all non\-zero exit codes are ignored.229Alternatively, provide a comma\-separated list of exit codes to ignore,230for example \fB\-\-ignore\-failure=1,2\fR.231An explicit value must be attached to the option with an equals sign.232.HP233\fB\-\-style\fR \fITYPE\fP234.IP235Set output style \fITYPE\fP (default: auto). Set this to 'basic' to disable output236coloring and interactive elements. Set it to 'full' to enable all effects even237if no interactive terminal was detected. Set this to 'nocolor' to keep the238interactive output without any colors. Set this to 'color' to keep the colors239without any interactive output. Set this to 'none' to disable all the output240of the tool.241.HP242\fB\-\-sort\fR \fIMETHOD\fP243.IP244Specify the sort order of the speed comparison summary and the245exported tables for markup formats (Markdown, AsciiDoc, org\-mode):246.RS247.IP "auto (default)"248the speed comparison will be ordered by time and249the markup tables will be ordered by command (input order).250.IP "command"251order benchmarks in the way they were specified252.IP "mean\-time"253order benchmarks by mean runtime254.RE255.HP256\fB\-u\fR, \fB\-\-time\-unit\fR \fIUNIT\fP257.IP258Set the time unit to be used. If the option is not given, the time unit is259determined automatically. Possible values:260.RS261.IP "microsecond"262Aliases: µs, us, microseconds.263.IP "millisecond"264Aliases: ms, milliseconds.265.IP "second"266Aliases: s, seconds.267.IP "minute"268Aliases: min, minutes.269.IP "hour"270Aliases: h, hours.271.RE272.IP273This option affects the standard output as well as all export formats274except for CSV and JSON.275.HP276\fB\-\-export\-asciidoc\fR \fIFILE\fP 277.IP278Export the timing summary statistics as an AsciiDoc table to the given \fIFILE\fP.279The output time unit can be changed using the \fB\-\-time\-unit\fR option.280.HP281\fB\-\-export\-csv\fR \fIFILE\fP282.IP283Export the timing summary statistics as CSV to the given \fIFILE\fP. If you need the284timing results for each individual run, use the JSON export format.285The output time unit is always seconds.286.HP287\fB\-\-export\-json\fR \fIFILE\fP288.IP289Export the timing summary statistics and timings of individual runs as JSON to290the given \fIFILE\fP. The output time unit is always seconds.291.HP292\fB\-\-export\-markdown\fR \fIFILE\fP293.IP294Export the timing summary statistics as a Markdown table to the given \fIFILE\fP.295The output time unit can be changed using the \fB\-\-time\-unit\fR option.296.HP297\fB\-\-export\-orgmode\fR \fIFILE\fP298.IP299Export the timing summary statistics as an Emacs org\-mode table to the300given \fIFILE\fP. The output time unit can be changed using the \fB\-\-time\-unit\fR option.301.HP302\fB\-\-show\-output\fR303.IP304Print the stdout and stderr of the benchmark instead of suppressing it. This305will increase the time it takes for benchmarks to run, so it should only be306used for debugging purposes or when trying to benchmark output speed.307.HP308\fB\-\-output\fR \fIWHERE\fP309.IP310Control where the output of the benchmark is redirected. Note that311some programs like 'grep' detect when standard output is \fI\,/dev/null\/\fP and312apply certain optimizations. To avoid that, consider using313\-\-output=pipe.314.IP315\fIWHERE\fP can be:316.RS317.IP null318Redirect output to \fI\,/dev/null\/\fP (the default).319.IP pipe320Feed the output through a pipe before discarding it.321.IP inherit322Don't redirect the output at all (same as \&'\-\-show\-output').323.IP "<FILE>"324Write the output to the given file.325.RE326.IP327This option can be specified once for all commands or multiple times,328once for each command. Note: If you want to log the output of each and329every iteration, you can use a shell redirection and the $HYPERFINE_ITERATION330environment variable: 'my-command > output-${HYPERFINE_ITERATION}.log'331.HP332\fB\-\-input\fR \fIWHERE\fP333.IP334Control where the input of the benchmark comes from.335.IP336\fIWHERE\fP can be:337.RS338.IP null339Read from \fI\,/dev/null\/\fP (the default).340.IP "<FILE>"341Read the input from the given file.342.RE343.HP344\fB\-n\fR, \fB\-\-command\-name\fR \fINAME\fP345.IP346Give a meaningful \fINAME\fP to a command. This can be specified multiple times347if several commands are benchmarked.348.HP349\fB\-h\fR, \fB\-\-help\fR350.IP351Print help352.HP353\fB\-V\fR, \fB\-\-version\fR354.IP355Print version356.SH EXAMPLES357.LP358Basic benchmark of 'find . -name todo.txt':359.RS360.nf361\fBhyperfine\fR 'find . -name todo.txt'362.fi363.RE364.LP365Perform benchmarks for 'sleep 0.2' and 'sleep 3.2' with a minimum 5 runs each:366.RS367.nf368\fBhyperfine\fR \fB\-\-min\-runs\fR 5 'sleep 0.2' 'sleep 3.2'369.fi370.RE371.LP372Perform a benchmark of 'grep' with a warm disk cache by executing 3 runs up front that are not part373of the measurement: 374.RS375.nf376\fBhyperfine\fR \fB\-\-warmup\fR 3 'grep -R TODO *'377.fi378.RE379.LP380Export the results of a parameter scan benchmark to a markdown table: 381.RS382.nf383\fBhyperfine\fR \fB\-\-export\-markdown\fR output.md \fB\-\-parameter-scan\fR time 1 5 'sleep {time}'384.fi385.RE386.LP387Demonstrate when each of \fB\-\-setup\fR, \fB\-\-prepare\fR, \fB\-\-conclude\fR, \fIcmd\fP and \fB\-\-cleanup\fR will run:388.RS389.nf390\fBhyperfine\fR \fB\-L\fR n 1,2 \fB\-r\fR 2 \fB\-\-show-output\fR \\391 \fB\-\-setup\fR 'echo setup n={n}' \\392 \fB\-\-prepare\fR 'echo prepare={n}' \\393 \fB\-\-conclude\fR 'echo conclude={n}' \\394 \fB\-\-cleanup\fR 'echo cleanup n={n}' \\395 'echo command n={n}'396.fi397.RE398.SH AUTHOR399.LP400David Peter <mail@david-peter.de>401.LP402Source, bug tracker, and additional information can be found on GitHub:403.I https://github.com/sharkdp/hyperfine