diff --git a/src/hyperfine/benchmark.rs b/src/hyperfine/benchmark.rs index 72e2b78..1a87bd5 100644 --- a/src/hyperfine/benchmark.rs +++ b/src/hyperfine/benchmark.rs @@ -219,7 +219,10 @@ pub fn run_benchmark( let count = { let min = cmp::max(runs_in_min_time, options.runs.min); - options.runs.max.as_ref() + options + .runs + .max + .as_ref() .map(|max| cmp::min(min, *max)) .unwrap_or(min) }; diff --git a/src/hyperfine/export/markdown.rs b/src/hyperfine/export/markdown.rs index 6948bdf..5fc3f3c 100644 --- a/src/hyperfine/export/markdown.rs +++ b/src/hyperfine/export/markdown.rs @@ -34,6 +34,7 @@ fn add_table_row(dest: &mut Vec, entry: &BenchmarkResult) { entry.stddev * MULTIPLIER, entry.min * MULTIPLIER, entry.max * MULTIPLIER - ).as_bytes(), + ) + .as_bytes(), ); } diff --git a/src/hyperfine/internal.rs b/src/hyperfine/internal.rs index e3d0789..85f280a 100644 --- a/src/hyperfine/internal.rs +++ b/src/hyperfine/internal.rs @@ -71,12 +71,13 @@ pub fn write_benchmark_comparison(results: &Vec) { let ratio = item.mean / fastest_item.mean; // https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulas // Covariance asssumed to be 0, i.e. variables are assumed to be independent - let ratio_stddev = ratio * ( (item.stddev/item.mean).powi(2) + (fastest_item.stddev/fastest_item.mean).powi(2) ).sqrt(); + let ratio_stddev = ratio + * ((item.stddev / item.mean).powi(2) + + (fastest_item.stddev / fastest_item.mean).powi(2)) + .sqrt(); println!( "{} ± {} times faster than '{}'", - format!("{:8.2}", ratio) - .bold() - .green(), + format!("{:8.2}", ratio).bold().green(), format!("{:.2}", ratio_stddev).green(), &item.command.magenta() ); diff --git a/src/hyperfine/types.rs b/src/hyperfine/types.rs index c19cb06..1ecb54c 100644 --- a/src/hyperfine/types.rs +++ b/src/hyperfine/types.rs @@ -84,10 +84,7 @@ pub struct Runs { impl Default for Runs { fn default() -> Runs { - Runs { - min: 10, - max: None, - } + Runs { min: 10, max: None } } } diff --git a/src/main.rs b/src/main.rs index 371de0f..30fc6ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,7 @@ mod hyperfine; use hyperfine::app::get_arg_matches; use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark}; -use hyperfine::error::{ParameterScanError, OptionsError}; +use hyperfine::error::{OptionsError, ParameterScanError}; use hyperfine::export::{ExportManager, ExportType}; use hyperfine::internal::write_benchmark_comparison; use hyperfine::types::{ @@ -168,11 +168,13 @@ fn build_hyperfine_options(matches: &ArgMatches) -> Result OutputStyleOption::Full, Some("basic") => OutputStyleOption::Basic, Some("nocolor") => OutputStyleOption::NoColor, - _ => if !options.show_output && atty::is(Stream::Stdout) { - OutputStyleOption::Full - } else { - OutputStyleOption::Basic - }, + _ => { + if !options.show_output && atty::is(Stream::Stdout) { + OutputStyleOption::Full + } else { + OutputStyleOption::Basic + } + } }; // We default Windows to NoColor if full had been specified.