Skip to content
Myr

Implement basic --parameter-list with naive list parsing

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Hasan Ibraheem · committed by David Peter · parent 538691e · Browse files · 2 files+31 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+31 added−0 removed

  • other:+31 added−0 removed

2 files+31 added−0 removed

modified:src/hyperfine/app.rs+15 added
128 unmodified lines
129 This performs benchmarks for 'sleep 0.3', 'sleep 0.5' and 'sleep 0.7'.",130 ),131 )132 .arg(133 Arg::with_name("parameter-list")134 .long("parameter-list")135 .short("L")136 .takes_value(true)137 .allow_hyphen_values(true)138 .value_names(&["VAR", "VALUES"])139 .conflicts_with("parameter-scan")140 .help(141 "Perform benchmark runs for each value in the comma-seperated list VALUES. \142 Replaces the string '{VAR}' in each command by the current parameter value\143 .\n\nExample: hyperfine -L threads 1,2,4 'make -j {threads}'\n\n\144 This performs benchmarks for 'make -j 1', 'make -j 2', and 'make -j 4'.",145 ),146 )147 .arg(148 Arg::with_name("style")149 .long("style")150 .short("s")151 .takes_value(true)
78 unmodified lines
modified:src/main.rs+16 added
206 unmodified lines
207 match get_parameterized_commands(command_strings, args, step_size) {208 Ok(commands) => commands,209 Err(e) => error(e.description()),210 }211 } else if let Some(mut args) = matches.values_of("parameter-list") {212 let param_name = args.next().unwrap();213 let param_list_str = args.next().unwrap();214215 let param_list = param_list_str.split(',').collect::<Vec<&str>>();216 let command_list = command_strings.collect::<Vec<&str>>();217218 let mut commands = Vec::with_capacity(param_list.len() * command_list.len());219220 for value in param_list {221 for cmd in &command_list {222 commands.push(Command::new_parametrized(cmd, param_name, value.to_string()));223 }224 }225226 commands227 } else {228 command_strings.map(Command::new).collect()229 }230}