Skip to content
Myr

hyperfine.1

This file

Path

doc/hyperfine.1

390 lines · 11.8 KiB

Last changed by

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

History of this file

Take it

1.TH HYPERFINE 12.SH NAME3hyperfine \- command\-line benchmarking tool4.SH SYNOPSIS5.B hyperfine6.RB [ \-hVNS ]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 [ \-\-prepare19.IR CMD ]20.RB [ \-\-conclude21.IR CMD ]22.RB [ \-\-cleanup23.IR CMD ]24.RB [ \-\-parameter\-scan25.IR VAR26.IR MIN27.IR MAX ]28.RB [ \-\-parameter\-step\-size29.IR DELTA ]30.RB [ \-\-parameter\-list31.IR VAR32.IR VALUES ]33.RB [ \-\-shell34.IR SHELL ]35.RB [ \-\-style36.IR TYPE ]37.RB [ \-\-metrics38.IR METRIC[:UNIT],...|default|time|all ]39.RB [ \-\-export\-asciidoc40.IR FILE ]41.RB [ \-\-export\-csv42.IR FILE ]43.RB [ \-\-export\-json44.IR FILE ]45.RB [ \-\-export\-markdown46.IR FILE ]47.RB [ \-\-export\-orgmode48.IR FILE ]49.RB [ \-\-output50.IR WHERE ]51.RB [ \-\-input52.IR WHERE ]53.RB [ \-\-command\-name54.IR NAME ]55.RI [ COMMAND... ]56.SH DESCRIPTION57A command\-line benchmarking tool which includes:58.LP59.RS60* Statistical analysis across multiple runs61.RE62.RS63* Support for arbitrary shell commands64.RE65.RS66* Constant feedback about the benchmark progress and current estimates67.RE68.RS69* Warmup runs can be executed before the actual benchmark70.RE71.RS72* Cache-clearing commands can be set up before each benchmark run73.RE74.RS75* Statistical outlier detection to detect interference from other programs and caching effects76.RE77.RS78* Export results to various formats: CSV, JSON, Markdown, AsciiDoc79.RE80.RS81* Parameterized benchmarks (e.g. vary the number of threads)82.RE83.SH OPTIONS84.HP85\fB\-w\fR, \fB\-\-warmup\fR \fINUM\fP86.IP87Perform \fINUM\fP warmup runs before the actual benchmark. This can be used88to fill (disk) caches for I/O\-heavy programs.89.HP90\fB\-m\fR, \fB\-\-min\-runs\fR \fINUM\fP91.IP92Perform at least \fINUM\fP runs for each command. Default: 10.93.HP94\fB\-M\fR, \fB\-\-max\-runs\fR \fINUM\fP95.IP96Perform at most \fINUM\fP runs for each command. By default, there is no97limit.98.HP99\fB\-r\fR, \fB\-\-runs\fR \fINUM\fP100.IP101Perform exactly \fINUM\fP runs for each command. If this option is not specified,102\fBhyperfine\fR automatically determines the number of runs.103.HP104\fB\-s\fR, \fB\-\-setup\fR \fICMD...\fP105.IP106Execute \fICMD\fP once before each set of benchmark runs. This is useful107for compiling your software with the provided parameters, or to do any108other work that should happen once before a series of benchmark runs,109not every time as would happen with the \fB\-\-prepare\fR option.110.HP111\fB\-p\fR, \fB\-\-prepare\fR \fICMD...\fP112.IP113Execute \fICMD\fP before each benchmark run. This is useful for clearing disk caches,114for example.115The \fB\-\-prepare\fR option can be specified once for all commands or multiple times,116once for each command. In the latter case, each preparation command will be117run prior to the corresponding benchmark command.118.HP119\fB\-C\fR, \fB\-\-conclude\fR \fICMD...\fP120.IP121Execute \fICMD\fP after each benchmark 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 per series of132benchmark runs, as opposed to the \fB\-\-conclude\fR option which runs after133every 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\-\-prepare\fR 'make clean' \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 shell150arithmetic.151.IP152.RS153Example:154.RS155\fBhyperfine\fR \fB\-\-shell=bash\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, which must be positive.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 g++,clang++ '{compiler} \-O2 main.cpp'187.RE188.RE189.IP190This performs benchmarks for 'g++ \-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\-\-shell\fR \fISHELL\fP196.IP197Set the shell to use for executing commands (default: none). 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 platform shell (sh on Unix, cmd.exe on Windows). 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.204This option also applies to setup, prepare, conclude, and cleanup commands.205.HP206\fB\-S\fR207.IP208An alias for '\-\-shell=default' (sh on Unix, cmd.exe on Windows).209.HP210\fB\-N\fR211.IP212An alias for '\-\-shell=none'.213.HP214\fB\-i\fR, \fB\-\-ignore\-failure\fR[=\fIMODE\fP]215.IP216Ignore failures of the benchmarked programs. Without a value or with217\fBall\-non\-zero\fR, all non\-zero exit codes are ignored.218Alternatively, provide a comma\-separated list of exit codes to ignore,219for example \fB\-\-ignore\-failure=1,2\fR.220An explicit value must be attached to the option with an equals sign.221.HP222\fB\-\-style\fR \fITYPE\fP223.IP224Set output style \fITYPE\fP (default: auto). Set this to 'basic' to disable output225coloring and interactive elements. Set it to 'full' to enable all effects even226if no interactive terminal was detected. Set this to 'nocolor' to keep the227interactive output without any colors. Set this to 'color' to keep the colors228without any interactive output. Set this to 'none' to disable all the output229of the tool.230.HP231\fB\-\-metrics\fR \fIMETRIC[:UNIT],...|default|time|all\fP232.IP233Select the metrics to display, in order, with an optional unit for each.234Default: \fBtime_wall_clock,memory_peak_resident\fR, or \fBtime_wall_clock\fR235on Windows, where peak resident memory is not yet supported.236.IP237Use \fBdefault\fR for the platform defaults, \fBtime\fR for238\fBtime_wall_clock,time_cpu,time_user,time_system\fR, or \fBall\fR for all available239metrics in the order listed below.240.IP241Time metrics \fBtime_wall_clock\fR, \fBtime_cpu\fR, \fBtime_user\fR, and \fBtime_system\fR242accept units \fBns\fR, \fBus\fR, \fBms\fR, \fBs\fR, \fBmin\fR, and \fBh\fR.243Peak memory, \fBmemory_peak_resident\fR, accepts \fBB\fR, \fBkB\fR,244\fBMB\fR, \fBGB\fR, \fBTB\fR, \fBKiB\fR, \fBMiB\fR, \fBGiB\fR,245and \fBTiB\fR.246.IP247Counter metrics \fBcpu_cycles\fR, \fBinstructions\fR, \fBcache_references\fR,248\fBcache_misses\fR, and \fBbranch_misses\fR accept \fBcount\fR (unscaled),249\fBk\fR (thousand), \fBM\fR (million), and \fBB\fR (billion).250.IP251If a unit is omitted, terminal and markup output automatically select a suitable252unit.253.RS254Example:255.RS256\fBhyperfine\fR \fB\-\-metrics\fR memory_peak_resident:MiB,time_wall_clock:ms,instructions:B './baseline' './candidate'257.RE258.RE259.HP260\fB\-\-export\-asciidoc\fR \fIFILE\fP 261.IP262Export the primary metric's summary statistics as an AsciiDoc table to the given263\fIFILE\fP. Use its selected unit, or choose a unit automatically when omitted.264.HP265\fB\-\-export\-csv\fR \fIFILE\fP266.IP267Export the primary metric's summary statistics as CSV to the given \fIFILE\fP,268identifying the metric and unit explicitly. Use the explicitly selected unit,269or the base unit (seconds, bytes, or unscaled counts) when omitted.270.HP271\fB\-\-export\-json\fR \fIFILE\fP272.IP273Export summary statistics and individual samples for all collected metrics as274JSON to the given \fIFILE\fP. Include the primary metric, and always use base275units (seconds, bytes, or unscaled counts), regardless of display settings.276.HP277\fB\-\-export\-markdown\fR \fIFILE\fP278.IP279Export the primary metric's summary statistics as a Markdown table to the given280\fIFILE\fP. Use its selected unit, or choose a unit automatically when omitted.281.HP282\fB\-\-export\-orgmode\fR \fIFILE\fP283.IP284Export the primary metric's summary statistics as an Emacs org\-mode table to285the given \fIFILE\fP. Use its selected unit, or choose a unit automatically286when omitted.287.HP288\fB\-\-show\-output\fR289.IP290Print the stdout and stderr of the benchmark instead of suppressing it. This291will increase the time it takes for benchmarks to run, so it should only be292used for debugging purposes or when trying to benchmark output speed.293.HP294\fB\-\-output\fR \fIWHERE\fP295.IP296Control where the output of the benchmark is redirected. Note that297some programs like 'grep' detect when standard output is \fI\,/dev/null\/\fP and298apply certain optimizations. To avoid that, consider using299\-\-output=pipe.300.IP301\fIWHERE\fP can be:302.RS303.IP null304Redirect output to \fI\,/dev/null\/\fP (the default).305.IP pipe306Feed the output through a pipe before discarding it.307.IP inherit308Don't redirect the output at all (same as \&'\-\-show\-output').309.IP "<FILE>"310Write the output to the given file.311.RE312.IP313This option can be specified once for all commands or multiple times,314once for each command. Note: If you want to log the output of each and315every iteration, you can use a shell redirection and the $HYPERFINE_ITERATION316environment variable (requires \fB\-S\fR / \fB\-\-shell=default\fR):317'my-command > output-${HYPERFINE_ITERATION}.log'318.HP319\fB\-\-input\fR \fIWHERE\fP320.IP321Control where the input of the benchmark comes from.322.IP323\fIWHERE\fP can be:324.RS325.IP null326Read from \fI\,/dev/null\/\fP (the default).327.IP "<FILE>"328Read the input from the given file.329.RE330.HP331\fB\-n\fR, \fB\-\-command\-name\fR \fINAME\fP332.IP333Give a meaningful \fINAME\fP to a command. This can be specified multiple times334if several commands are benchmarked.335.HP336\fB\-h\fR, \fB\-\-help\fR337.IP338Print help339.HP340\fB\-V\fR, \fB\-\-version\fR341.IP342Print version343.SH EXAMPLES344.LP345Basic benchmark of 'find . -name todo.txt':346.RS347.nf348\fBhyperfine\fR 'find . -name todo.txt'349.fi350.RE351.LP352Perform benchmarks for 'sleep 0.2' and 'sleep 3.2' with a minimum 5 runs each:353.RS354.nf355\fBhyperfine\fR \fB\-\-min\-runs\fR 5 'sleep 0.2' 'sleep 3.2'356.fi357.RE358.LP359Perform a benchmark of 'grep' with a warm disk cache by executing 3 runs up front that are not part360of the measurement: 361.RS362.nf363\fBhyperfine\fR \fB\-S\fR \fB\-\-warmup\fR 3 'grep -R TODO *'364.fi365.RE366.LP367Export the results of a parameter scan benchmark to a markdown table: 368.RS369.nf370\fBhyperfine\fR \fB\-\-export\-markdown\fR output.md \fB\-\-parameter-scan\fR time 1 5 'sleep {time}'371.fi372.RE373.LP374Demonstrate when each of \fB\-\-setup\fR, \fB\-\-prepare\fR, \fB\-\-conclude\fR, \fIcmd\fP and \fB\-\-cleanup\fR will run:375.RS376.nf377\fBhyperfine\fR \fB\-L\fR n 1,2 \fB\-r\fR 2 \fB\-\-show-output\fR \\378	\fB\-\-setup\fR 'echo setup n={n}' \\379	\fB\-\-prepare\fR 'echo prepare={n}' \\380	\fB\-\-conclude\fR 'echo conclude={n}' \\381	\fB\-\-cleanup\fR 'echo cleanup n={n}' \\382	'echo command n={n}'383.fi384.RE385.SH AUTHOR386.LP387David Peter <mail@david-peter.de>388.LP389Source, bug tracker, and additional information can be found on GitHub:390.I https://github.com/sharkdp/hyperfine