Skip to content
Myr

Fix remaining clippy warnings

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

authored by David Peter · committed by David Peter · parent 85730b3 · Browse files · 7 files+44 added−24 removed
This commit

State

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

Diff stats

7 files+44 added−24 removed

  • other:+44 added−24 removed

7 files+44 added−24 removed

modified:src/hyperfine/export/csv.rs+1 added-2 removed
30 unmodified lines
31 writer.write_record(headers)?;32 }3334 for res in results {35 let mut fields = Vec::new();36 fields.push(Cow::Borrowed(res.command.as_bytes()));35 let mut fields = vec![Cow::Borrowed(res.command.as_bytes())];36 for f in &[37 res.mean, res.stddev, res.median, res.user, res.system, res.min, res.max,38 ] {39 fields.push(Cow::Owned(f.to_string().into_bytes()))
68 unmodified lines
modified:src/hyperfine/timer/unix_timer.rs+1 added
48 unmodified lines
49 };5051 const MICROSEC_PER_SEC: i64 = 1000 * 1000;5253 #[allow(clippy::useless_conversion)]54 CPUTimes {55 user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC56 + i64::from(result.ru_utime.tv_usec),57 system_usec: i64::from(result.ru_stime.tv_sec) * MICROSEC_PER_SEC
39 unmodified lines
modified:src/hyperfine/benchmark.rs+27 added-10 removed
145 unmodified lines
146 times_system.push(r.time_system);147 }148 }149150 if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }150 if let Some(bar) = progress_bar.as_ref() {151 bar.inc(1)152 }153 }154153 if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }155 if let Some(bar) = progress_bar.as_ref() {156 bar.finish_and_clear()157 }158159 Ok(TimingResult {160 time_real: mean(&times_real),161 time_user: mean(&times_user),
117 unmodified lines
279 options.show_output,280 options.failure_action,281 None,282 )?;279 if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }283 if let Some(bar) = progress_bar.as_ref() {284 bar.inc(1)285 }286 }281 if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }287 if let Some(bar) = progress_bar.as_ref() {288 bar.finish_and_clear()289 }290 }291292 // Set up progress bar (and spinner for initial measurement)293 let progress_bar = if options.output_style != OutputStyleOption::Disabled {
44 unmodified lines
338339 all_succeeded = all_succeeded && success;340341 // Re-configure the progress bar334 if let Some(bar) = progress_bar.as_ref() { bar.set_length(count) }335 if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }342 if let Some(bar) = progress_bar.as_ref() {343 bar.set_length(count)344 }345 if let Some(bar) = progress_bar.as_ref() {346 bar.inc(1)347 }348349 // Gather statistics350 for _ in 0..count_remaining {351 run_preparation_command(&options.shell, &prepare_cmd, options.show_output)?;
2 unmodified lines
354 let mean = format_duration(mean(&times_real), options.time_unit);355 format!("Current estimate: {}", mean.to_string().green())356 };357346 if let Some(bar) = progress_bar347 .as_ref() { bar.set_message(msg.to_owned()) }358 if let Some(bar) = progress_bar.as_ref() {359 bar.set_message(msg.to_owned())360 }361362 let (res, status) = time_shell_command(363 &options.shell,364 cmd,
9 unmodified lines
374 exit_codes.push(extract_exit_code(status));375376 all_succeeded = all_succeeded && success;377365 if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }378 if let Some(bar) = progress_bar.as_ref() {379 bar.inc(1)380 }381 }382368 if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }383 if let Some(bar) = progress_bar.as_ref() {384 bar.finish_and_clear()385 }386387 // Compute statistical quantities388 let t_num = times_real.len();389 let t_mean = mean(&times_real);
95 unmodified lines
modified:src/hyperfine/format.rs+2 added-3 removed
1 unmodified line
23/// Format the given duration as a string. The output-unit can be enforced by setting `unit` to4/// `Some(target_unit)`. If `unit` is `None`, it will be determined automatically.5pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {6 match format_duration_unit(duration, unit) {7 (duration_fmt, _) => duration_fmt,8 }6 let (duration_fmt, _) = format_duration_unit(duration, unit);7 duration_fmt8}910/// Like `format_duration`, but returns the target unit as well.11pub fn format_duration_unit(duration: Second, unit: Option<Unit>) -> (String, Unit) {
54 unmodified lines
modified:src/hyperfine/parameter_range.rs+2 added-1 removed
116 unmodified lines
117 for value in param_range {118 for cmd in &command_strings {119 let name = command_names120 .get(i)121 .or_else(|| command_names.get(0)).copied();121 .or_else(|| command_names.get(0))122 .copied();123 commands.push(Command::new_parametrized(124 name,125 cmd,126 vec![(param_name, ParameterValue::Numeric(value.into()))],
188 unmodified lines
modified:src/hyperfine/types.rs+7 added-6 removed
28 unmodified lines
29 }30 }31}3233impl Into<NumericType> for i32 {34 fn into(self) -> NumericType {35 NumericType::Int(self)33impl From<i32> for NumericType {34 fn from(x: i32) -> NumericType {35 NumericType::Int(x)36 }37}3839impl Into<NumericType> for Decimal {40 fn into(self) -> NumericType {41 NumericType::Decimal(self)39impl From<Decimal> for NumericType {40 fn from(x: Decimal) -> NumericType {41 NumericType::Decimal(x)42 }43}4445impl TryFrom<NumericType> for usize {
278 unmodified lines
324}325326impl BenchmarkResult {327 /// Create a new entry with the given values.328 #[allow(clippy::too_many_arguments)]329 pub fn new(330 command: String,331 mean: Second,332 stddev: Second,
24 unmodified lines
modified:src/main.rs+4 added-2 removed
95 unmodified lines
96 let param_to_u64 = |param| {97 matches98 .value_of(param)99 .map(|n| {100 n.parse::<u64>()100 u64::from_str_radix(n, 10).map_err(|e| OptionsError::NumericParsingError(param, e))101 .map_err(|e| OptionsError::NumericParsingError(param, e))102 })103 .transpose()104 };105
164 unmodified lines
270 let mut index = vec![0usize; dimensions.len()];271 'outer: loop {272 let name = command_names273 .get(i)273 .or_else(|| command_names.get(0)).copied();274 .or_else(|| command_names.get(0))275 .copied();276 i += 1;277278 let (command_index, params_indices) = index.split_first().unwrap();279 let parameters = param_names_and_values
128 unmodified lines