mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Pass Copyable enums by value
This commit is contained in:
1 parent
78d249d656
commit
16210a1d13
4 files changed
+11
-11
No files matched your search
@@ -90,7 +90,7 @@ pub fn time_shell_command(
|
||||
/// Measure the average shell spawning time
|
||||
pub fn mean_shell_spawning_time(
|
||||
shell: &str,
|
||||
style: &OutputStyleOption,
|
||||
style: OutputStyleOption,
|
||||
show_output: bool,
|
||||
) -> io::Result<TimingResult> {
|
||||
const COUNT: u64 = 200;
|
||||
@@ -210,7 +210,7 @@ pub fn run_benchmark(
|
||||
let progress_bar = get_progress_bar(
|
||||
options.warmup_count,
|
||||
"Performing warmup runs",
|
||||
&options.output_style,
|
||||
options.output_style,
|
||||
);
|
||||
|
||||
for _ in 0..options.warmup_count {
|
||||
@@ -230,7 +230,7 @@ pub fn run_benchmark(
|
||||
let progress_bar = get_progress_bar(
|
||||
options.runs.min,
|
||||
"Initial time measurement",
|
||||
&options.output_style,
|
||||
options.output_style,
|
||||
);
|
||||
|
||||
// Run init command
|
||||
|
||||
@@ -11,15 +11,15 @@ use std::iter::Iterator;
|
||||
pub const MIN_EXECUTION_TIME: Second = 5e-3;
|
||||
|
||||
/// Return a pre-configured progress bar
|
||||
pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> ProgressBar {
|
||||
let progressbar_style = match *option {
|
||||
pub fn get_progress_bar(length: u64, msg: &str, option: OutputStyleOption) -> ProgressBar {
|
||||
let progressbar_style = match option {
|
||||
OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),
|
||||
_ => ProgressStyle::default_spinner()
|
||||
.tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")
|
||||
.template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),
|
||||
};
|
||||
|
||||
let progress_bar = match *option {
|
||||
let progress_bar = match option {
|
||||
OutputStyleOption::Basic | OutputStyleOption::Color => ProgressBar::hidden(),
|
||||
_ => ProgressBar::new(length),
|
||||
};
|
||||
|
||||
@@ -14,16 +14,16 @@ pub enum Unit {
|
||||
|
||||
impl Unit {
|
||||
/// The abbreviation of the Unit.
|
||||
pub fn short_name(&self) -> String {
|
||||
match *self {
|
||||
pub fn short_name(self) -> String {
|
||||
match self {
|
||||
Unit::Second => String::from("s"),
|
||||
Unit::MilliSecond => String::from("ms"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the Second value formatted for the Unit.
|
||||
pub fn format(&self, value: Second) -> String {
|
||||
match *self {
|
||||
pub fn format(self, value: Second) -> String {
|
||||
match self {
|
||||
Unit::Second => format!("{:.3}", value),
|
||||
Unit::MilliSecond => format!("{:.1}", value * 1e3),
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ fn run(
|
||||
options: &HyperfineOptions,
|
||||
) -> io::Result<Vec<BenchmarkResult>> {
|
||||
let shell_spawning_time =
|
||||
mean_shell_spawning_time(&options.shell, &options.output_style, options.show_output)?;
|
||||
mean_shell_spawning_time(&options.shell, options.output_style, options.show_output)?;
|
||||
|
||||
let mut timing_results = vec![];
|
||||
|
||||
|
||||
Reference in new issue
Block a user