mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-09-11 14:07:02 +03:00
Add a --show-elapsed
flag to optionally enable a the elapsed time counter.
This commit is contained in:
parent
e996be124e
commit
4e8cb3fec0
@ -180,6 +180,7 @@ impl<'a> Executor for ShellExecutor<'a> {
|
|||||||
COUNT,
|
COUNT,
|
||||||
"Measuring shell spawning time",
|
"Measuring shell spawning time",
|
||||||
self.options.output_style,
|
self.options.output_style,
|
||||||
|
self.options.show_elapsed,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -155,6 +155,7 @@ impl<'a> Benchmark<'a> {
|
|||||||
self.options.warmup_count,
|
self.options.warmup_count,
|
||||||
"Performing warmup runs",
|
"Performing warmup runs",
|
||||||
self.options.output_style,
|
self.options.output_style,
|
||||||
|
self.options.show_elapsed,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -178,6 +179,7 @@ impl<'a> Benchmark<'a> {
|
|||||||
self.options.run_bounds.min,
|
self.options.run_bounds.min,
|
||||||
"Initial time measurement",
|
"Initial time measurement",
|
||||||
self.options.output_style,
|
self.options.output_style,
|
||||||
|
self.options.show_elapsed,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -111,6 +111,14 @@ fn build_command() -> Command {
|
|||||||
artifacts that need to be cleaned up."
|
artifacts that need to be cleaned up."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("show-elapsed")
|
||||||
|
.long("show-elapsed")
|
||||||
|
.action(ArgAction::SetTrue)
|
||||||
|
.help(
|
||||||
|
"Show time elapsed since the benchmarking runs were started."
|
||||||
|
)
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("parameter-scan")
|
Arg::new("parameter-scan")
|
||||||
.long("parameter-scan")
|
.long("parameter-scan")
|
||||||
|
@ -233,6 +233,9 @@ pub struct Options {
|
|||||||
|
|
||||||
/// Which time unit to use when displaying results
|
/// Which time unit to use when displaying results
|
||||||
pub time_unit: Option<Unit>,
|
pub time_unit: Option<Unit>,
|
||||||
|
|
||||||
|
/// Show elapsed time since current run start.
|
||||||
|
pub show_elapsed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
@ -252,6 +255,7 @@ impl Default for Options {
|
|||||||
command_output_policy: CommandOutputPolicy::Null,
|
command_output_policy: CommandOutputPolicy::Null,
|
||||||
time_unit: None,
|
time_unit: None,
|
||||||
command_input_policy: CommandInputPolicy::Null,
|
command_input_policy: CommandInputPolicy::Null,
|
||||||
|
show_elapsed: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,6 +423,10 @@ impl Options {
|
|||||||
CommandInputPolicy::Null
|
CommandInputPolicy::Null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if matches.get_flag("show-elapsed") {
|
||||||
|
options.show_elapsed = true;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(options)
|
Ok(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,22 @@ const TICK_SETTINGS: (&str, u64) = ("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ ", 80);
|
|||||||
const TICK_SETTINGS: (&str, u64) = (r"+-x| ", 200);
|
const TICK_SETTINGS: (&str, u64) = (r"+-x| ", 200);
|
||||||
|
|
||||||
/// Return a pre-configured progress bar
|
/// Return a pre-configured progress bar
|
||||||
pub fn get_progress_bar(length: u64, msg: &str, option: OutputStyleOption) -> ProgressBar {
|
pub fn get_progress_bar(
|
||||||
|
length: u64,
|
||||||
|
msg: &str,
|
||||||
|
option: OutputStyleOption,
|
||||||
|
show_elapsed: bool,
|
||||||
|
) -> ProgressBar {
|
||||||
|
let template_str = match show_elapsed {
|
||||||
|
true => " {spinner} {msg:<30} {wide_bar} ET {elapsed_precise} ETA {eta_precise} ",
|
||||||
|
false => " {spinner} {msg:<30} {wide_bar} ETA {eta_precise} ",
|
||||||
|
};
|
||||||
|
|
||||||
let progressbar_style = match option {
|
let progressbar_style = match option {
|
||||||
OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),
|
OutputStyleOption::Basic | OutputStyleOption::Color => ProgressStyle::default_bar(),
|
||||||
_ => ProgressStyle::default_spinner()
|
_ => ProgressStyle::default_spinner()
|
||||||
.tick_chars(TICK_SETTINGS.0)
|
.tick_chars(TICK_SETTINGS.0)
|
||||||
.template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise} ")
|
.template(template_str)
|
||||||
.expect("no template error"),
|
.expect("no template error"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user