mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
Implement basic --parameter-list with naive list parsing
This commit is contained in:
1 parent
538691e999
commit
4a5d08ddc2
2 files changed
+31
No files matched your search
@@ -129,6 +129,21 @@ fn build_app() -> App<'static, 'static> {
|
|||||||
This performs benchmarks for 'sleep 0.3', 'sleep 0.5' and 'sleep 0.7'.",
|
This performs benchmarks for 'sleep 0.3', 'sleep 0.5' and 'sleep 0.7'.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("parameter-list")
|
||||||
|
.long("parameter-list")
|
||||||
|
.short("L")
|
||||||
|
.takes_value(true)
|
||||||
|
.allow_hyphen_values(true)
|
||||||
|
.value_names(&["VAR", "VALUES"])
|
||||||
|
.conflicts_with("parameter-scan")
|
||||||
|
.help(
|
||||||
|
"Perform benchmark runs for each value in the comma-seperated list VALUES. \
|
||||||
|
Replaces the string '{VAR}' in each command by the current parameter value\
|
||||||
|
.\n\nExample: hyperfine -L threads 1,2,4 'make -j {threads}'\n\n\
|
||||||
|
This performs benchmarks for 'make -j 1', 'make -j 2', and 'make -j 4'.",
|
||||||
|
),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("style")
|
Arg::with_name("style")
|
||||||
.long("style")
|
.long("style")
|
||||||
|
|||||||
+16
@@ -208,6 +208,22 @@ fn build_commands<'a>(matches: &'a ArgMatches<'_>) -> Vec<Command<'a>> {
|
|||||||
Ok(commands) => commands,
|
Ok(commands) => commands,
|
||||||
Err(e) => error(e.description()),
|
Err(e) => error(e.description()),
|
||||||
}
|
}
|
||||||
|
} else if let Some(mut args) = matches.values_of("parameter-list") {
|
||||||
|
let param_name = args.next().unwrap();
|
||||||
|
let param_list_str = args.next().unwrap();
|
||||||
|
|
||||||
|
let param_list = param_list_str.split(',').collect::<Vec<&str>>();
|
||||||
|
let command_list = command_strings.collect::<Vec<&str>>();
|
||||||
|
|
||||||
|
let mut commands = Vec::with_capacity(param_list.len() * command_list.len());
|
||||||
|
|
||||||
|
for value in param_list {
|
||||||
|
for cmd in &command_list {
|
||||||
|
commands.push(Command::new_parametrized(cmd, param_name, value.to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commands
|
||||||
} else {
|
} else {
|
||||||
command_strings.map(Command::new).collect()
|
command_strings.map(Command::new).collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user