mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Use String instead of NumericType for paramater in Command
This commit is contained in:
1 parent
7fe65c569f
commit
538691e999
3 files changed
+11
-11
No files matched your search
@@ -225,7 +225,7 @@ pub fn run_benchmark(
|
||||
&values[num]
|
||||
};
|
||||
match cmd.get_parameter() {
|
||||
Some((param, value)) => Command::new_parametrized(preparation_command, param, value),
|
||||
Some((param, value)) => Command::new_parametrized(preparation_command, param, value.clone()),
|
||||
None => Command::new(preparation_command),
|
||||
}
|
||||
});
|
||||
@@ -421,7 +421,7 @@ pub fn run_benchmark(
|
||||
.cleanup_command
|
||||
.as_ref()
|
||||
.map(|cleanup_command| match cmd.get_parameter() {
|
||||
Some((param, value)) => Command::new_parametrized(cleanup_command, param, value),
|
||||
Some((param, value)) => Command::new_parametrized(cleanup_command, param, value.clone()),
|
||||
None => Command::new(cleanup_command),
|
||||
});
|
||||
run_cleanup_command(&options.shell, &cleanup_cmd, options.show_output)?;
|
||||
@@ -436,6 +436,6 @@ pub fn run_benchmark(
|
||||
t_min,
|
||||
t_max,
|
||||
times_real,
|
||||
cmd.get_parameter().map(|p| p.1),
|
||||
cmd.get_parameter().as_ref().map(|p| p.1.clone()),
|
||||
))
|
||||
}
|
||||
@@ -92,7 +92,7 @@ fn build_parameterized_commands<'a, T: Numeric>(
|
||||
|
||||
for value in param_range {
|
||||
for cmd in &command_strings {
|
||||
commands.push(Command::new_parametrized(cmd, param_name, value.into()));
|
||||
commands.push(Command::new_parametrized(cmd, param_name, value.into().to_string()));
|
||||
}
|
||||
}
|
||||
Ok(commands)
|
||||
|
||||
@@ -46,7 +46,7 @@ pub struct Command<'a> {
|
||||
expression: &'a str,
|
||||
|
||||
/// A possible parameter value.
|
||||
parameter: Option<(&'a str, NumericType)>,
|
||||
parameter: Option<(&'a str, String)>,
|
||||
}
|
||||
|
||||
impl<'a> Command<'a> {
|
||||
@@ -60,7 +60,7 @@ impl<'a> Command<'a> {
|
||||
pub fn new_parametrized(
|
||||
expression: &'a str,
|
||||
parameter: &'a str,
|
||||
value: NumericType,
|
||||
value: String,
|
||||
) -> Command<'a> {
|
||||
Command {
|
||||
expression,
|
||||
@@ -69,7 +69,7 @@ impl<'a> Command<'a> {
|
||||
}
|
||||
|
||||
pub fn get_shell_command(&self) -> String {
|
||||
match self.parameter {
|
||||
match &self.parameter {
|
||||
Some((param_name, param_value)) => self.expression.replace(
|
||||
&format!("{{{param_name}}}", param_name = param_name),
|
||||
¶m_value.to_string(),
|
||||
@@ -78,8 +78,8 @@ impl<'a> Command<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_parameter(&self) -> Option<(&'a str, NumericType)> {
|
||||
self.parameter
|
||||
pub fn get_parameter(&self) -> &Option<(&'a str, String)> {
|
||||
&self.parameter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ pub struct BenchmarkResult {
|
||||
|
||||
/// Any parameter used
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub parameter: Option<NumericType>,
|
||||
pub parameter: Option<String>,
|
||||
}
|
||||
|
||||
impl BenchmarkResult {
|
||||
@@ -231,7 +231,7 @@ impl BenchmarkResult {
|
||||
min: Second,
|
||||
max: Second,
|
||||
times: Vec<Second>,
|
||||
parameter: Option<NumericType>,
|
||||
parameter: Option<String>,
|
||||
) -> Self {
|
||||
BenchmarkResult {
|
||||
command,
|
||||
|
||||
Reference in new issue
Block a user