diff --git a/CHANGELOG.md b/CHANGELOG.md index 68dd4a1..fbae85c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Features - Disable colorized output in case of `TERM=dumb` or `NO_COLOR=1`, see #542 and #555 (@nabijaczleweli) +- Add new (experimental) `--min-benchmarking-time ` option, see #527 (@sharkdp) ## Changes diff --git a/src/cli.rs b/src/cli.rs index 200382d..75f8e23 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -294,6 +294,17 @@ fn build_command() -> Command<'static> { .help("Give a meaningful name to a command. This can be specified multiple times \ if several commands are benchmarked."), ) + // This option is hidden for now, as it is not yet clear yet if we want to 'stabilize' this, + // see discussion in https://github.com/sharkdp/hyperfine/issues/527 + .arg( + Arg::new("min-benchmarking-time") + .long("min-benchmarking-time") + .takes_value(true) + .hide(true) + .help("Set the minimum time (in seconds) to run benchmarks. Note that the number of \ + benchmark runs is additionally influenced by the `--min-runs`, `--max-runs`, and \ + `--runs` option.") + ) .arg( Arg::new("debug-mode") .long("debug-mode") diff --git a/src/error.rs b/src/error.rs index c24e9ec..a38bbd3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use std::num::{self, ParseIntError}; +use std::num::{self, ParseFloatError, ParseIntError}; use rust_decimal::Error as DecimalError; use thiserror::Error; @@ -43,8 +43,10 @@ pub enum OptionsError<'a> { TooManyCommandNames(usize), #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")] UnexpectedCommandNameCount(usize, usize), - #[error("Could not read numeric argument to '--{0}': {1}")] - NumericParsingError(&'a str, ParseIntError), + #[error("Could not read numeric integer argument to '--{0}': {1}")] + IntParsingError(&'a str, ParseIntError), + #[error("Could not read numeric floating point argument to '--{0}': {1}")] + FloatParsingError(&'a str, ParseFloatError), #[error("An empty command has been specified for the '--shell ' option")] EmptyShell, #[error("Failed to parse '--shell ' expression as command line: {0}")] diff --git a/src/options.rs b/src/options.rs index edd2391..8ec74ab 100644 --- a/src/options.rs +++ b/src/options.rs @@ -226,7 +226,7 @@ impl Options { .value_of(param) .map(|n| { n.parse::() - .map_err(|e| OptionsError::NumericParsingError(param, e)) + .map_err(|e| OptionsError::IntParsingError(param, e)) }) .transpose() }; @@ -345,6 +345,12 @@ impl Options { _ => None, }; + if let Some(time) = matches.value_of("min-benchmarking-time") { + options.min_benchmarking_time = time + .parse::() + .map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?; + } + Ok(options) }