mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 01:00:31 +00:00
Support matrices of independent parameter lists
This patch permits the `-L`/`--parameter-list` argument to appear multiple times. Each additional parameter increases the dimensionality of the parameter matrix. One benchmark will be run for each combination of parameters (i.e., the benchmark space is the Cartesian product of the parameter spaces). For now, `--parameter-list` and `--parameter-scan` are still mutually exclusive. If desired, a follow-up change could similarly permit multiple occurrences of `--parameter-scan` and also permit use of both listed and scanned parameters together. (After all, `--parameter-scan` can be thought of as syntactic sugar for a parameter list.) This implementation is a little profligate with memory usage for `BenchmarkResult`s: each result contains a separate copy of all parameter names (as `String`s). This could be done away with by threading lifetimes through the `BenchmarkResult`s, or by ref-counting the names. Because `BenchmarkResult`s now have maps with arbitrary key sets, we can no longer use `serde` to serialize them to CSV. But a CSV writer is easy to write by hand, so we just do that. Fixes #253. Test Plan: Some unit tests included. As an integration test, try: ``` cargo run --release -- --runs 10 \ -L foo foo1,foo2 -L bar bar9,bar8 \ 'echo {foo} {bar}' \ 'printf "%s\n" {foo} {bar}' \ --export-csv /tmp/out ``` with all the export formats. wchargin-branch: param-list-matrix wchargin-source: 11051ab222c9de0fbc6ac6a080fbca48e05996c2
This commit is contained in:
1 parent
5a80a23bdc
commit
f6464a2943
9 files changed
+286
-78
No files matched your search
@@ -223,12 +223,7 @@ pub fn run_benchmark(
|
||||
} else {
|
||||
&values[num]
|
||||
};
|
||||
match cmd.get_parameter() {
|
||||
Some((param, value)) => {
|
||||
Command::new_parametrized(preparation_command, param, value.clone())
|
||||
}
|
||||
None => Command::new(preparation_command),
|
||||
}
|
||||
Command::new_parametrized(preparation_command, cmd.get_parameters().clone())
|
||||
});
|
||||
|
||||
// Warmup phase
|
||||
@@ -414,16 +409,9 @@ pub fn run_benchmark(
|
||||
}
|
||||
|
||||
// Run cleanup command
|
||||
let cleanup_cmd =
|
||||
options
|
||||
.cleanup_command
|
||||
.as_ref()
|
||||
.map(|cleanup_command| match cmd.get_parameter() {
|
||||
Some((param, value)) => {
|
||||
Command::new_parametrized(cleanup_command, param, value.clone())
|
||||
}
|
||||
None => Command::new(cleanup_command),
|
||||
});
|
||||
let cleanup_cmd = options.cleanup_command.as_ref().map(|cleanup_command| {
|
||||
Command::new_parametrized(cleanup_command, cmd.get_parameters().clone())
|
||||
});
|
||||
run_cleanup_command(&options.shell, &cleanup_cmd, options.show_output)?;
|
||||
|
||||
Ok(BenchmarkResult::new(
|
||||
@@ -436,6 +424,9 @@ pub fn run_benchmark(
|
||||
t_min,
|
||||
t_max,
|
||||
times_real,
|
||||
cmd.get_parameter().as_ref().map(|p| p.1.to_string()),
|
||||
cmd.get_parameters()
|
||||
.iter()
|
||||
.map(|(name, value)| ((*name).to_string(), value.to_string()))
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
Reference in new issue
Block a user