update output condition check to use .map

This commit is contained in:
knidarkness authored and David Peter committed 2019-10-15 17:49:48 +02:00
1 parent 34eb150fef
commit b3084cbb58
1 file changed
+15 -25
+15 -25
View File
@@ -141,14 +141,12 @@ pub fn mean_shell_spawning_time(
times_system.push(r.time_system); times_system.push(r.time_system);
} }
} }
if let Some(ref bar) = progress_bar {
bar.inc(1); progress_bar.as_ref().map(|bar| bar.inc(1));
}
}
if let Some(ref bar) = progress_bar {
bar.finish_and_clear();
} }
progress_bar.as_ref().map(|bar| bar.finish_and_clear());
Ok(TimingResult { Ok(TimingResult {
time_real: mean(&times_real), time_real: mean(&times_real),
time_user: mean(&times_user), time_user: mean(&times_user),
@@ -253,13 +251,11 @@ pub fn run_benchmark(
options.failure_action, options.failure_action,
None, None,
)?; )?;
if let Some(ref pbar) = progress_bar { progress_bar.as_ref().map(|bar| bar.inc(1));
pbar.inc(1);
}
}
if let Some(ref bar) = progress_bar {
bar.finish_and_clear();
} }
progress_bar.as_ref().map(|bar| bar.finish_and_clear());
} }
// Set up progress bar (and spinner for initial measurement) // Set up progress bar (and spinner for initial measurement)
@@ -310,10 +306,8 @@ pub fn run_benchmark(
all_succeeded = all_succeeded && success; all_succeeded = all_succeeded && success;
// Re-configure the progress bar // Re-configure the progress bar
if let Some(ref bar) = progress_bar { progress_bar.as_ref().map(|bar| bar.set_length(count));
bar.set_length(count); progress_bar.as_ref().map(|bar| bar.inc(1));
bar.inc(1);
}
// Gather statistics // Gather statistics
for _ in 0..count_remaining { for _ in 0..count_remaining {
@@ -324,9 +318,7 @@ pub fn run_benchmark(
format!("Current estimate: {}", mean.to_string().green()) format!("Current estimate: {}", mean.to_string().green())
}; };
if let Some(ref bar) = progress_bar { progress_bar.as_ref().map(|bar| bar.set_message(&msg));
bar.set_message(&msg);
}
let (res, success) = time_shell_command( let (res, success) = time_shell_command(
&options.shell, &options.shell,
@@ -342,14 +334,12 @@ pub fn run_benchmark(
all_succeeded = all_succeeded && success; all_succeeded = all_succeeded && success;
if let Some(ref bar) = progress_bar { progress_bar.as_ref().map(|bar| bar.inc(1));
bar.inc(1);
}
}
if let Some(ref bar) = progress_bar {
bar.finish_and_clear();
} }
progress_bar.as_ref().map(|bar| bar.finish_and_clear());
// Compute statistical quantities // Compute statistical quantities
let t_num = times_real.len(); let t_num = times_real.len();
let t_mean = mean(&times_real); let t_mean = mean(&times_real);