mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 09:01:25 +00:00
1 parent
4b9cd06d86
commit
a8752769ab
11 files changed
+85
-10
No files matched your search
@@ -12,6 +12,11 @@ pub struct BenchmarkResult {
|
||||
/// The full command line of the program that is being benchmarked
|
||||
pub command: String,
|
||||
|
||||
/// The full command line of the program that is being benchmarked, possibly including a list of
|
||||
/// parameters that were not used in the command line template.
|
||||
#[serde(skip_serializing)]
|
||||
pub command_with_unused_parameters: String,
|
||||
|
||||
/// The average run time
|
||||
pub mean: Second,
|
||||
|
||||
|
||||
@@ -112,13 +112,12 @@ impl<'a> Benchmark<'a> {
|
||||
|
||||
/// Run the benchmark for a single command
|
||||
pub fn run(&self) -> Result<BenchmarkResult> {
|
||||
let command_name = self.command.get_name();
|
||||
if self.options.output_style != OutputStyleOption::Disabled {
|
||||
println!(
|
||||
"{}{}: {}",
|
||||
"Benchmark ".bold(),
|
||||
(self.number + 1).to_string().bold(),
|
||||
command_name,
|
||||
self.command.get_name_with_unused_parameters(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -369,7 +368,8 @@ impl<'a> Benchmark<'a> {
|
||||
self.run_cleanup_command(self.command.get_parameters().iter().cloned())?;
|
||||
|
||||
Ok(BenchmarkResult {
|
||||
command: command_name,
|
||||
command: self.command.get_name(),
|
||||
command_with_unused_parameters: self.command.get_name_with_unused_parameters(),
|
||||
mean: t_mean,
|
||||
stddev: t_stddev,
|
||||
median: t_median,
|
||||
|
||||
@@ -89,6 +89,7 @@ fn create_result(name: &str, mean: Scalar) -> BenchmarkResult {
|
||||
|
||||
BenchmarkResult {
|
||||
command: name.into(),
|
||||
command_with_unused_parameters: name.into(),
|
||||
mean,
|
||||
stddev: Some(1.0),
|
||||
median: mean,
|
||||
|
||||
@@ -68,18 +68,21 @@ impl<'a> Scheduler<'a> {
|
||||
let others = &annotated_results[1..];
|
||||
|
||||
println!("{}", "Summary".bold());
|
||||
println!(" '{}' ran", fastest.result.command.cyan());
|
||||
println!(
|
||||
" {} ran",
|
||||
fastest.result.command_with_unused_parameters.cyan()
|
||||
);
|
||||
|
||||
for item in others {
|
||||
println!(
|
||||
"{}{} times faster than '{}'",
|
||||
"{}{} times faster than {}",
|
||||
format!("{:8.2}", item.relative_speed).bold().green(),
|
||||
if let Some(stddev) = item.relative_speed_stddev {
|
||||
format!(" ± {}", format!("{:.2}", stddev).green())
|
||||
} else {
|
||||
"".into()
|
||||
},
|
||||
&item.result.command.magenta()
|
||||
&item.result.command_with_unused_parameters.magenta()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user