Fix panic on --runs 0 (#923)

* fix: reject --runs/--max-runs 0, clamp --min-runs to 1

* Validate positive run counts with clap

---------

Co-authored-by: VXNCXNX <VXNCXNX@users.noreply.github.com>
Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
authored and GitHub committed 2026-10-02 09:56:27 +00:00
1 parent 8d908b0754
commit 907de26344
3 files changed
+37 -14

No files matched your search

+4
View File
@@ -41,6 +41,7 @@ fn build_command() -> Command {
.short('w')
.value_name("NUM")
.action(ArgAction::Set)
.value_parser(clap::value_parser!(u64))
.help(
"Perform NUM warmup runs before the actual benchmark. This can be used \
to fill (disk) caches for I/O-heavy programs.",
@@ -52,6 +53,7 @@ fn build_command() -> Command {
.short('m')
.action(ArgAction::Set)
.value_name("NUM")
.value_parser(clap::value_parser!(u64).range(1..))
.help("Perform at least NUM runs for each command (default: 10)."),
)
.arg(
@@ -60,6 +62,7 @@ fn build_command() -> Command {
.short('M')
.action(ArgAction::Set)
.value_name("NUM")
.value_parser(clap::value_parser!(u64).range(1..))
.help("Perform at most NUM runs for each command. By default, there is no limit."),
)
.arg(
@@ -69,6 +72,7 @@ fn build_command() -> Command {
.short('r')
.action(ArgAction::Set)
.value_name("NUM")
.value_parser(clap::value_parser!(u64).range(1..))
.help("Perform exactly NUM runs for each command. If this option is not specified, \
hyperfine automatically determines the number of runs."),
)