Skip to content
Myr

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

4 files+11 added−11 removed

modified:src/hyperfine/benchmark.rs+3 added-3 removed
88 unmodified lines
8990/// Measure the average shell spawning time91pub 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 lines
209 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 );215216 for _ in 0..options.warmup_count {217 let _ = time_shell_command(
11 unmodified lines
229 // 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 );235236 // Run init command237 let prepare_cmd = options
169 unmodified lines
modified:src/hyperfine/internal.rs+3 added-3 removed
9 unmodified lines
10/// Threshold for warning about fast execution time11pub const MIN_EXECUTION_TIME: Second = 5e-3;1213/// Return a pre-configured progress bar14pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> ProgressBar {15 let progressbar_style = match *option {14pub 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 };2122 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 lines
modified:src/hyperfine/units.rs+4 added-4 removed
12 unmodified lines
13}1415impl 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 }2324 /// 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 lines
modified:src/main.rs+1 added-1 removed
30 unmodified lines
31 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)?;3637 let mut timing_results = vec![];3839 // Run the benchmarks
186 unmodified lines