Implement slowness checking and --reference flag to use a command as a reference when printing or exporting summary#579
Implement slowness checking and --reference flag to use a command as a reference when printing or exporting summary#579Animeshz wants to merge 2 commits intosharkdp:masterfrom
Conversation
…a reference when printing or exporting summary
|
Example run: $ hyperfine -N --reference 'bash -c "echo \"Hello, World!\""' -L shell dash,fish '{shell} -c "echo \"Hello, world!\""'
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/hyperfine -N --reference 'bash -c "echo \"Hello, World'\!'\""' -L shell dash,fish '{shell} -c "echo \"Hello, world'\!'\""'`
Benchmark 1: bash -c "echo \"Hello, World!\""
Time (mean ± σ): 4.0 ms ± 0.1 ms [User: 2.8 ms, System: 1.1 ms]
Range (min … max): 3.7 ms … 4.9 ms 677 runs
Benchmark 2: dash -c "echo \"Hello, world!\""
Time (mean ± σ): 1.1 ms ± 0.1 ms [User: 0.3 ms, System: 0.7 ms]
Range (min … max): 0.9 ms … 1.6 ms 2489 runs
Benchmark 3: fish -c "echo \"Hello, world!\""
Time (mean ± σ): 56.2 ms ± 0.8 ms [User: 41.6 ms, System: 20.1 ms]
Range (min … max): 54.4 ms … 58.2 ms 54 runs
Summary
'bash -c "echo \"Hello, World!\""' ran
3.72 ± 0.25 times slower than 'dash -c "echo \"Hello, world!\""'
14.06 ± 0.42 times faster than 'fish -c "echo \"Hello, world!\""'
|
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Thank you very much for your contribution!
What does "slowness checking" mean? |
| pub is_reference: bool, | ||
| pub is_faster: bool, |
There was a problem hiding this comment.
Maybe rename the latter to
| pub is_reference: bool, | |
| pub is_faster: bool, | |
| pub is_reference: bool, | |
| pub is_faster_than_reference: bool, |
Thinking about this some more, it's actually not clear what the value of the latter bool should be for the case where is_reference is true. So maybe introduce an enum instead pub enum RelativeOrdering { Reference, FasterThanReference, SlowerThanReference } and use this instead of the two bool ("make illegal states unrepresentable"):
| pub is_reference: bool, | |
| pub is_faster: bool, | |
| pub relative_ordering: RelativeOrdering, |
What do you think?
| .options | ||
| .reference_command | ||
| .as_ref() | ||
| .map(|cmd| Command::new(None, &cmd)); |
There was a problem hiding this comment.
| .map(|cmd| Command::new(None, &cmd)); | |
| .map(|cmd| Command::new(None, cmd)); |
| .takes_value(true) | ||
| .number_of_values(1) | ||
| .value_name("CMD") | ||
| .help("The reference command to measure the results against."), |
There was a problem hiding this comment.
| .help("The reference command to measure the results against."), | |
| .help("The reference command for the relative comparison of results. If this is unset, results are compared with the fastest command as reference."), |
| /// Whether or not to ignore non-zero exit codes | ||
| pub command_failure_action: CmdFailureAction, | ||
|
|
||
| /// Command to run before each *batch* of timing runs, i.e. before each individual benchmark |
| .arg( | ||
| Arg::new("reference") | ||
| .long("reference") | ||
| .short('R') |
There was a problem hiding this comment.
Let's not introduce a short command line option for this right away. We can always add it later if this is really a commonly used option.
|
Closing this in favor of #744 |
As title enlists.
Closes #577.