Addressed review comments.

This commit is contained in:
Diogo Sousa authored and David Peter committed 2018-09-09 23:18:18 +02:00
1 parent d78c33b864
commit 0466a1d7cf
4 files changed
+12 -8

No files matched your search

+1
View File
@@ -65,6 +65,7 @@ fn build_app() -> App<'static, 'static> {
.arg(
Arg::with_name("runs")
.long("runs")
.conflicts_with_all(&["max-runs", "min-runs"])
.short("r")
.takes_value(true)
.value_name("NUM")
+7 -4
View File
@@ -216,10 +216,13 @@ pub fn run_benchmark(
/ (res.time_real + prepare_res.time_real + shell_spawning_time.time_real))
as u64;
let count = cmp::min(
cmp::max(runs_in_min_time, options.runs.min),
options.runs.max
);
let count = {
let min = cmp::max(runs_in_min_time, options.runs.min);
options.runs.max.as_ref()
.map(|max| cmp::min(min, *max))
.unwrap_or(min)
};
let count_remaining = count - 1;
+2 -2
View File
@@ -79,14 +79,14 @@ pub struct Runs {
pub min: u64,
/// Maximum number of benchmark runs
pub max: u64,
pub max: Option<u64>,
}
impl Default for Runs {
fn default() -> Runs {
Runs {
min: 10,
max: ::std::u64::MAX,
max: None,
}
}
}
+2 -2
View File
@@ -148,14 +148,14 @@ fn build_hyperfine_options(matches: &ArgMatches) -> Result<HyperfineOptions, Opt
(None, Some(max)) => {
// Since the minimum was not explicit we lower it if max is below the default min.
options.runs.min = cmp::min(options.runs.min, max);
options.runs.max = max;
options.runs.max = Some(max);
}
(Some(min), Some(max)) if min > max => {
return Err(OptionsError::EmptyRunsRange);
}
(Some(min), Some(max)) => {
options.runs.min = min;
options.runs.max = max;
options.runs.max = Some(max);
}
(None, None) => {}
};