Skip to content
Myr

Support parameter in preparation command

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

authored by Tuomas Siipola · committed by David Peter · parent 4d68c5f · Browse files · 2 files+16 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

2 files+16 added−10 removed

  • other:+16 added−10 removed

2 files+16 added−10 removed

modified:src/hyperfine/benchmark.rs+12 added-10 removed
129 unmodified lines
130}131132/// Run the command specified by `--prepare`.133fn run_preparation_command(134 command: &Option<String>,134 command: &Option<Command>,135 show_output: bool,136) -> io::Result<TimingResult> {137 if let &Some(ref preparation_command) = command {138 let res = time_shell_command(139 &Command::new(preparation_command),140 show_output,141 CmdFailureAction::RaiseError,142 None,143 );137 if let Some(ref cmd) = command {138 let res = time_shell_command(cmd, show_output, CmdFailureAction::RaiseError, None);139 if res.is_err() {140 return Err(io::Error::new(141 io::ErrorKind::Other,142 "The preparation command terminated with a non-zero exit code. \
49 unmodified lines
192 &options.output_style,193 );194195 // Run init / cleanup command196 let prepare_cmd = options197 .preparation_command198 .as_ref()199 .map(|preparation_command| match cmd.get_parameter() {200 Some((param, value)) => Command::new_parametrized(preparation_command, param, value),201 None => Command::new(preparation_command),202 });201 let prepare_res = run_preparation_command(&options.preparation_command, options.show_output)?;203 let prepare_res = run_preparation_command(&prepare_cmd, options.show_output)?;204205 // Initial timing run206 let (res, success) = time_shell_command(207 cmd,
26 unmodified lines
234 progress_bar.set_length(count_remaining);235236 // Gather statistics237 for _ in 0..count_remaining {236 run_preparation_command(&options.preparation_command, options.show_output)?;238 run_preparation_command(&prepare_cmd, options.show_output)?;239240 let msg = {241 let mean = format_duration(mean(&times_real), None);242 format!("Current estimate: {}", mean.to_string().green())
99 unmodified lines
modified:src/hyperfine/types.rs+4 added
36 unmodified lines
37 ),38 None => self.expression.into(),39 }40 }4142 pub fn get_parameter(&self) -> Option<(&'a str, i32)> {43 self.parameter44 }45}4647impl<'a> fmt::Display for Command<'a> {48 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118 unmodified lines