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:
Saurav Sharma authored and David Peter committed 2019-10-13 15:11:39 +02:00
1 parent 0c0713da30
commit bc82bd5f23
2 files changed
+12 -5

No files matched your search

+10
View File
@@ -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)?);