mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 01:00:31 +00:00
Add multiple --prepare support
Signed-off-by: Saurav Sharma <appdroiddeveloper@gmail.com>
This commit is contained in:
1 parent
2c3ced9333
commit
0c0713da30
5 files changed
+36
-12
No files matched your search
@@ -234,13 +234,17 @@ pub fn run_benchmark(
|
||||
);
|
||||
|
||||
// Run init command
|
||||
let prepare_cmd = options
|
||||
.preparation_command
|
||||
.as_ref()
|
||||
.map(|preparation_command| match cmd.get_parameter() {
|
||||
Some((param, value)) => Command::new_parametrized(preparation_command, param, value),
|
||||
None => Command::new(preparation_command),
|
||||
});
|
||||
let mut prepare_cmd = None;
|
||||
if let Some(values) = &options.preparation_command {
|
||||
if num >= values.len() {
|
||||
prepare_cmd = Some(new_command_from_get_parameter(
|
||||
cmd,
|
||||
&values[values.len() - 1],
|
||||
));
|
||||
} else {
|
||||
prepare_cmd = Some(new_command_from_get_parameter(cmd, &values[num]));
|
||||
}
|
||||
};
|
||||
let prepare_res = run_preparation_command(&options.shell, &prepare_cmd, options.show_output)?;
|
||||
|
||||
// Initial timing run
|
||||
@@ -404,3 +408,14 @@ pub fn run_benchmark(
|
||||
cmd.get_parameter().map(|p| p.1),
|
||||
))
|
||||
}
|
||||
|
||||
// Get out new Command from a Command and preparation command
|
||||
fn new_command_from_get_parameter<'a>(
|
||||
cmd: &Command<'a>,
|
||||
preparation_command: &'a str,
|
||||
) -> Command<'a> {
|
||||
match cmd.get_parameter() {
|
||||
Some((param, value)) => Command::new_parametrized(preparation_command, param, value),
|
||||
None => Command::new(preparation_command),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user