mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-29 16:38:56 +00:00
raise error if preparation_command length is not equal to command or 1
Signed-off-by: Saurav Sharma <appdroiddeveloper@gmail.com>
This commit is contained in:
1 parent
0c0713da30
commit
bc82bd5f23
2 files changed
+12
-5
No files matched your search
@@ -236,11 +236,8 @@ pub fn run_benchmark(
|
||||
// Run init 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],
|
||||
));
|
||||
if values.len() == 1 {
|
||||
prepare_cmd = Some(new_command_from_get_parameter(cmd, &values[0]));
|
||||
} else {
|
||||
prepare_cmd = Some(new_command_from_get_parameter(cmd, &values[num]));
|
||||
}
|
||||
|
||||
+10
@@ -33,6 +33,16 @@ fn run(commands: &[Command<'_>], options: &HyperfineOptions) -> io::Result<Vec<B
|
||||
|
||||
let mut timing_results = vec![];
|
||||
|
||||
// Check if preparation command is equal to command length or should be mentioned only once
|
||||
if let Some(preparation_command) = &options.preparation_command {
|
||||
if commands.len() != preparation_command.len() && preparation_command.len() > 1 {
|
||||
error(
|
||||
"--prepare option should be provided only 1 time or N times equal to number of \
|
||||
commands to benchmark",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the benchmarks
|
||||
for (num, cmd) in commands.iter().enumerate() {
|
||||
timing_results.push(run_benchmark(num, cmd, shell_spawning_time, options)?);
|
||||
|
||||
Reference in new issue
Block a user