Pass `Copy`able enums by value
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by philipp · committed by David Peter · parent 78d249d · Browse files · 4 files·+11 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+11 added−11 removed
- other:+11 added−11 removed
Provenance
- Commit
16210a1- Tree
7c876aa- Author
philipp <philipp>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
78d249d
4 files changed+11 added−11 removed
modified:src/hyperfine/benchmark.rs+3 added-3 removed
88 unmodified lines89 90 /// Measure the average shell spawning time91 pub fn mean_shell_spawning_time(92 shell: &str,93- style: &OutputStyleOption,93+ style: OutputStyleOption,94 show_output: bool,95 ) -> io::Result<TimingResult> {96 const COUNT: u64 = 200;97 let progress_bar = get_progress_bar(COUNT, "Measuring shell spawning time", style);111 unmodified lines209 if options.warmup_count > 0 {210 let progress_bar = get_progress_bar(211 options.warmup_count,212 "Performing warmup runs",213- &options.output_style,213+ options.output_style,214 );215 216 for _ in 0..options.warmup_count {217 let _ = time_shell_command(11 unmodified lines229 // Set up progress bar (and spinner for initial measurement)230 let progress_bar = get_progress_bar(231 options.runs.min,232 "Initial time measurement",233- &options.output_style,233+ options.output_style,234 );235 236 // Run init command237 let prepare_cmd = options169 unmodified linesmodified:src/hyperfine/internal.rs+3 added-3 removed
9 unmodified lines10 /// Threshold for warning about fast execution time11 pub const MIN_EXECUTION_TIME: Second = 5e-3;12 13 /// Return a pre-configured progress bar14-pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> ProgressBar {15- let progressbar_style = match *option {14+pub fn get_progress_bar(length: u64, msg: &str, option: OutputStyleOption) -> ProgressBar {15+ let progressbar_style = match option {16 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),17 _ => ProgressStyle::default_spinner()18 .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")19 .template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),20 };21 22- let progress_bar = match *option {22+ let progress_bar = match option {23 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressBar::hidden(),24 _ => ProgressBar::new(length),25 };26 progress_bar.set_style(progressbar_style.clone());122 unmodified linesmodified:src/hyperfine/units.rs+4 added-4 removed
12 unmodified lines13 }14 15 impl Unit {16 /// The abbreviation of the Unit.17- pub fn short_name(&self) -> String {18- match *self {17+ pub fn short_name(self) -> String {18+ match self {19 Unit::Second => String::from("s"),20 Unit::MilliSecond => String::from("ms"),21 }22 }23 24 /// Returns the Second value formatted for the Unit.25- pub fn format(&self, value: Second) -> String {26- match *self {25+ pub fn format(self, value: Second) -> String {26+ match self {27 Unit::Second => format!("{:.3}", value),28 Unit::MilliSecond => format!("{:.1}", value * 1e3),29 }30 }15 unmodified linesmodified:src/main.rs+1 added-1 removed
30 unmodified lines31 commands: &[Command<'_>],32 options: &HyperfineOptions,33 ) -> io::Result<Vec<BenchmarkResult>> {34 let shell_spawning_time =35- mean_shell_spawning_time(&options.shell, &options.output_style, options.show_output)?;35+ mean_shell_spawning_time(&options.shell, options.output_style, options.show_output)?;36 37 let mut timing_results = vec![];38 39 // Run the benchmarks186 unmodified lines