mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Allow forwarding benchmark's stdout to hyperfine
This change makes it possible to forward the stdout of the command the user tries to benchmark to hyperfine's stdout using the `--print-stdout` flag. This should be irrelevant for most use-cases, however it makes it possible to get some crude benchmarks of terminal emulators similar to what's currently often done with `time cat file`.
This commit is contained in:
1 parent
1011eef7f3
commit
4be435436e
5 files changed
+63
-21
No files matched your search
+5
-2
@@ -56,7 +56,8 @@ pub fn error(message: &str) -> ! {
|
||||
|
||||
/// Runs the benchmark for the given commands
|
||||
fn run(commands: &Vec<Command>, options: &HyperfineOptions) -> io::Result<Vec<BenchmarkResult>> {
|
||||
let shell_spawning_time = mean_shell_spawning_time(&options.output_style)?;
|
||||
let shell_spawning_time =
|
||||
mean_shell_spawning_time(&options.output_style, options.print_stdout)?;
|
||||
|
||||
let mut timing_results = vec![];
|
||||
|
||||
@@ -128,11 +129,13 @@ fn build_hyperfine_options(matches: &ArgMatches) -> HyperfineOptions {
|
||||
|
||||
options.preparation_command = matches.value_of("prepare").map(String::from);
|
||||
|
||||
options.print_stdout = matches.is_present("print-stdout");
|
||||
|
||||
options.output_style = match matches.value_of("style") {
|
||||
Some("full") => OutputStyleOption::Full,
|
||||
Some("basic") => OutputStyleOption::Basic,
|
||||
Some("nocolor") => OutputStyleOption::NoColor,
|
||||
_ => if atty::is(Stream::Stdout) {
|
||||
_ => if !options.print_stdout && atty::is(Stream::Stdout) {
|
||||
OutputStyleOption::Full
|
||||
} else {
|
||||
OutputStyleOption::Basic
|
||||
|
||||
Reference in new issue
Block a user