mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +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 count = {
|
||||||
let min = cmp::max(runs_in_min_time, options.runs.min);
|
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))
|
.map(|max| cmp::min(min, *max))
|
||||||
.unwrap_or(min)
|
.unwrap_or(min)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ fn add_table_row(dest: &mut Vec<u8>, entry: &BenchmarkResult) {
|
|||||||
entry.stddev * MULTIPLIER,
|
entry.stddev * MULTIPLIER,
|
||||||
entry.min * MULTIPLIER,
|
entry.min * MULTIPLIER,
|
||||||
entry.max * 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;
|
let ratio = item.mean / fastest_item.mean;
|
||||||
// https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulas
|
// https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulas
|
||||||
// Covariance asssumed to be 0, i.e. variables are assumed to be independent
|
// 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!(
|
println!(
|
||||||
"{} ± {} times faster than '{}'",
|
"{} ± {} times faster than '{}'",
|
||||||
format!("{:8.2}", ratio)
|
format!("{:8.2}", ratio).bold().green(),
|
||||||
.bold()
|
|
||||||
.green(),
|
|
||||||
format!("{:.2}", ratio_stddev).green(),
|
format!("{:.2}", ratio_stddev).green(),
|
||||||
&item.command.magenta()
|
&item.command.magenta()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -84,10 +84,7 @@ pub struct Runs {
|
|||||||
|
|
||||||
impl Default for Runs {
|
impl Default for Runs {
|
||||||
fn default() -> Runs {
|
fn default() -> Runs {
|
||||||
Runs {
|
Runs { min: 10, max: None }
|
||||||
min: 10,
|
|
||||||
max: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -42,7 +42,7 @@ mod hyperfine;
|
|||||||
|
|
||||||
use hyperfine::app::get_arg_matches;
|
use hyperfine::app::get_arg_matches;
|
||||||
use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};
|
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::export::{ExportManager, ExportType};
|
||||||
use hyperfine::internal::write_benchmark_comparison;
|
use hyperfine::internal::write_benchmark_comparison;
|
||||||
use hyperfine::types::{
|
use hyperfine::types::{
|
||||||
@@ -168,11 +168,13 @@ fn build_hyperfine_options(matches: &ArgMatches) -> Result<HyperfineOptions, Opt
|
|||||||
Some("full") => OutputStyleOption::Full,
|
Some("full") => OutputStyleOption::Full,
|
||||||
Some("basic") => OutputStyleOption::Basic,
|
Some("basic") => OutputStyleOption::Basic,
|
||||||
Some("nocolor") => OutputStyleOption::NoColor,
|
Some("nocolor") => OutputStyleOption::NoColor,
|
||||||
_ => if !options.show_output && atty::is(Stream::Stdout) {
|
_ => {
|
||||||
OutputStyleOption::Full
|
if !options.show_output && atty::is(Stream::Stdout) {
|
||||||
} else {
|
OutputStyleOption::Full
|
||||||
OutputStyleOption::Basic
|
} else {
|
||||||
},
|
OutputStyleOption::Basic
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// We default Windows to NoColor if full had been specified.
|
// We default Windows to NoColor if full had been specified.
|
||||||
|
|||||||
Reference in new issue
Block a user