mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-29 16:38:56 +00:00
cargo fmt
This commit is contained in:
1 parent
156933489b
commit
f85e61dc39
5 files changed
+20
-16
No files matched your search
@@ -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)
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@ fn add_table_row(dest: &mut Vec<u8>, entry: &BenchmarkResult) {
|
||||
entry.stddev * MULTIPLIER,
|
||||
entry.min * MULTIPLIER,
|
||||
entry.max * MULTIPLIER
|
||||
).as_bytes(),
|
||||
)
|
||||
.as_bytes(),
|
||||
);
|
||||
}
|
||||
@@ -71,12 +71,13 @@ pub fn write_benchmark_comparison(results: &Vec<BenchmarkResult>) {
|
||||
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()
|
||||
);
|
||||
|
||||
@@ -84,10 +84,7 @@ pub struct Runs {
|
||||
|
||||
impl Default for Runs {
|
||||
fn default() -> Runs {
|
||||
Runs {
|
||||
min: 10,
|
||||
max: None,
|
||||
}
|
||||
Runs { min: 10, max: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -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<HyperfineOptions, Opt
|
||||
Some("full") => 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.
|
||||
|
||||
Reference in new issue
Block a user