Add new (hidden) --min-benchmarking-time option

This commit is contained in:
David Peter authored and David Peter committed 2022-09-07 09:13:53 +02:00
1 parent 77e1b5e72f
commit dffbdc34d4
4 files changed
+24 -4

No files matched your search

+1
View File
@@ -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 <secs>` option, see #527 (@sharkdp)
## Changes
+11
View File
@@ -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")
+5 -3
View File
@@ -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 <command>' option")]
EmptyShell,
#[error("Failed to parse '--shell <command>' expression as command line: {0}")]
+7 -1
View File
@@ -226,7 +226,7 @@ impl Options {
.value_of(param)
.map(|n| {
n.parse::<u64>()
.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::<f64>()
.map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;
}
Ok(options)
}