Skip to content
Myr

Add option to name reference command

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

Add --reference-name option to give a reference command a name. This was discussed in the PR that added --reference, #744, but was unfortunately never implemented.

authored by Niklas Dewally · committed by David Peter · parent 835fc43 · Browse files · 4 files+28 added−1 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+28 added−1 removed

  • tests:+12 added−0 removed
  • other:+16 added−1 removed

4 files+28 added−1 removed

modified:src/benchmark/scheduler.rs+1 added-1 removed
40 unmodified lines
41 let reference = self42 .options43 .reference_command44 .as_ref()45 .map(|cmd| Command::new(None, cmd));45 .map(|cmd| Command::new(self.options.reference_name.as_deref(), cmd));4647 executor.calibrate()?;4849 for (number, cmd) in reference.iter().chain(self.commands.iter()).enumerate() {
179 unmodified lines
modified:src/cli.rs+8 added
95 unmodified lines
96 If this is unset, results are compared with the fastest command as reference."97 )98 )99 .arg(100 Arg::new("reference-name")101 .long("reference-name")102 .action(ArgAction::Set)103 .value_name("CMD")104 .help("Give a meaningful name to the reference command.")105 .requires("reference")106 )107 .arg(108 Arg::new("prepare")109 .long("prepare")110 .short('p')111 .action(ArgAction::Append)
297 unmodified lines
modified:src/options.rs+7 added
206 unmodified lines
207208 // Command to use as a reference for relative speed comparison209 pub reference_command: Option<String>,210211 // Name of the reference command212 pub reference_name: Option<String>,213214 /// Command(s) to run before each timing run215 pub preparation_command: Option<Vec<String>>,216217 /// Command(s) to run after each timing run
34 unmodified lines
252 warmup_count: 0,253 min_benchmarking_time: 3.0,254 command_failure_action: CmdFailureAction::RaiseError,255 reference_command: None,256 reference_name: None,257 preparation_command: None,258 conclusion_command: None,259 setup_command: None,260 cleanup_command: None,
52 unmodified lines
313314 options.setup_command = matches.get_one::<String>("setup").map(String::from);315316 options.reference_command = matches.get_one::<String>("reference").map(String::from);317 options.reference_name = matches318 .get_one::<String>("reference-name")319 .map(String::from);320321 options.preparation_command = matches322 .get_many::<String>("prepare")323 .map(|values| values.map(String::from).collect::<Vec<String>>());
209 unmodified lines
modified:tests/integration_tests.rs+12 added
498 unmodified lines
499 );500}501502#[test]503fn shows_reference_name() {504 hyperfine_debug()505 .arg("--reference=sleep 2.0")506 .arg("--reference-name=refabc123")507 .arg("sleep 1.0")508 .arg("sleep 3.0")509 .assert()510 .success()511 .stdout(predicate::str::contains("Benchmark 1: refabc123"));512}513514#[test]515fn performs_all_benchmarks_in_parameter_scan() {516 hyperfine_debug()517 .arg("--parameter-scan")518 .arg("time")
134 unmodified lines