Skip to content
Myr

Compact output, add `-s color` option, closes #70

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Strip the empty lines within the results for each benchmark, but keep the empty line between each benchmark, and before the summary. Add `color` style option to show color but not be interactive (no progress bar).

authored by Jason Peacock · committed by David Peter · parent 4b8f47d · Browse files · 5 files+14 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+14 added−10 removed

  • other:+14 added−10 removed

5 files+14 added−10 removed

modified:src/hyperfine/app.rs+3 added-2 removed
98 unmodified lines
99 .long("style")100 .short("s")101 .takes_value(true)102 .value_name("TYPE")103 .possible_values(&["auto", "basic", "full", "nocolor"])103 .possible_values(&["auto", "basic", "full", "nocolor", "color"])104 .help(105 "Set output style type (default: auto). Set this to 'basic' to disable output \106 coloring and interactive elements. Set it to 'full' to enable all effects \107 even if no interactive terminal was detected. Set this to 'nocolor' to \108 keep the interactive output without any colors.",108 keep the interactive output without any colors. Set this to 'color to' keep \109 the colors without any interactive output.",110 ),111 )112 .arg(113 Arg::with_name("ignore-failure")
39 unmodified lines
modified:src/hyperfine/benchmark.rs-2 removed
162 unmodified lines
163 "Benchmark #".bold(),164 (num + 1).to_string().bold(),165 cmd166 );167 println!();167168 let mut times_real: Vec<Second> = vec![];169 let mut times_user: Vec<Second> = vec![];170 let mut times_system: Vec<Second> = vec![];
120 unmodified lines
291 stddev_str.green(),292 user_str.blue(),293 system_str.blue()294 );296 println!(" ");295296 println!(297 " Range ({} … {}): {:>8} … {:>8}",298 "min".cyan(),
47 unmodified lines
modified:src/hyperfine/internal.rs+4 added-4 removed
10 unmodified lines
1112/// Return a pre-configured progress bar13pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> ProgressBar {14 let progressbar_style = match *option {15 OutputStyleOption::Basic => ProgressStyle::default_bar(),15 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),16 _ => ProgressStyle::default_spinner()17 .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")18 .template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),18 .template("\n {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),19 };2021 let progress_bar = match *option {22 OutputStyleOption::Basic => ProgressBar::hidden(),22 OutputStyleOption::Basic | OutputStyleOption::Color => ProgressBar::hidden(),23 _ => ProgressBar::new(length),24 };25 progress_bar.set_style(progressbar_style.clone());26 progress_bar.enable_steady_tick(80);
35 unmodified lines
62 fastest_item = run;63 }64 }6566 println!("{}\n", "Summary".bold());66 println!("{}", "Summary".bold());67 println!(" '{}' ran", fastest_item.command.cyan());68 longer_items.sort_by(|l, r| l.mean.partial_cmp(&r.mean).unwrap_or(Ordering::Equal));6970 for item in longer_items {
24 unmodified lines
modified:src/hyperfine/types.rs+3 added
69 unmodified lines
70 Full,7172 /// Keep elements such as progress bar, but use no coloring73 NoColor,7475 /// Keep coloring, but use no progress bar76 Color,77}7879/// Number of runs for a benchmark80pub struct Runs {
104 unmodified lines
modified:src/main.rs+4 added-2 removed
166 unmodified lines
167 options.output_style = match matches.value_of("style") {168 Some("full") => OutputStyleOption::Full,169 Some("basic") => OutputStyleOption::Basic,170 Some("nocolor") => OutputStyleOption::NoColor,171 Some("color") => OutputStyleOption::Color,172 _ => {173 if !options.show_output && atty::is(Stream::Stdout) {174 OutputStyleOption::Full175 } else {
6 unmodified lines
182 if cfg!(windows) && options.output_style == OutputStyleOption::Full {183 options.output_style = OutputStyleOption::NoColor;184 }185185 if options.output_style != OutputStyleOption::Full {186 colored::control::set_override(false);186 match options.output_style {187 OutputStyleOption::Full | OutputStyleOption::Color => colored::control::unset_override(),188 _ => colored::control::set_override(false),189 }190191 if matches.is_present("ignore-failure") {192 options.failure_action = CmdFailureAction::Ignore;
44 unmodified lines