mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-29 08:38:56 +00:00
Fix remaining clippy warnings
This commit is contained in:
1 parent
85730b3f0f
commit
068bebb4e6
7 files changed
+44
-24
No files matched your search
+27
-10
@@ -147,10 +147,14 @@ pub fn mean_shell_spawning_time(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.inc(1)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.finish_and_clear()
|
||||
}
|
||||
|
||||
Ok(TimingResult {
|
||||
time_real: mean(×_real),
|
||||
@@ -276,9 +280,13 @@ pub fn run_benchmark(
|
||||
options.failure_action,
|
||||
None,
|
||||
)?;
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.inc(1)
|
||||
}
|
||||
}
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.finish_and_clear()
|
||||
}
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }
|
||||
}
|
||||
|
||||
// Set up progress bar (and spinner for initial measurement)
|
||||
@@ -331,8 +339,12 @@ pub fn run_benchmark(
|
||||
all_succeeded = all_succeeded && success;
|
||||
|
||||
// Re-configure the progress bar
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.set_length(count) }
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.set_length(count)
|
||||
}
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.inc(1)
|
||||
}
|
||||
|
||||
// Gather statistics
|
||||
for _ in 0..count_remaining {
|
||||
@@ -343,8 +355,9 @@ pub fn run_benchmark(
|
||||
format!("Current estimate: {}", mean.to_string().green())
|
||||
};
|
||||
|
||||
if let Some(bar) = progress_bar
|
||||
.as_ref() { bar.set_message(msg.to_owned()) }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.set_message(msg.to_owned())
|
||||
}
|
||||
|
||||
let (res, status) = time_shell_command(
|
||||
&options.shell,
|
||||
@@ -362,10 +375,14 @@ pub fn run_benchmark(
|
||||
|
||||
all_succeeded = all_succeeded && success;
|
||||
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.inc(1)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }
|
||||
if let Some(bar) = progress_bar.as_ref() {
|
||||
bar.finish_and_clear()
|
||||
}
|
||||
|
||||
// Compute statistical quantities
|
||||
let t_num = times_real.len();
|
||||
|
||||
@@ -32,8 +32,7 @@ impl Exporter for CsvExporter {
|
||||
}
|
||||
|
||||
for res in results {
|
||||
let mut fields = Vec::new();
|
||||
fields.push(Cow::Borrowed(res.command.as_bytes()));
|
||||
let mut fields = vec![Cow::Borrowed(res.command.as_bytes())];
|
||||
for f in &[
|
||||
res.mean, res.stddev, res.median, res.user, res.system, res.min, res.max,
|
||||
] {
|
||||
|
||||
@@ -3,9 +3,8 @@ use crate::hyperfine::units::{Second, Unit};
|
||||
/// Format the given duration as a string. The output-unit can be enforced by setting `unit` to
|
||||
/// `Some(target_unit)`. If `unit` is `None`, it will be determined automatically.
|
||||
pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {
|
||||
match format_duration_unit(duration, unit) {
|
||||
(duration_fmt, _) => duration_fmt,
|
||||
}
|
||||
let (duration_fmt, _) = format_duration_unit(duration, unit);
|
||||
duration_fmt
|
||||
}
|
||||
|
||||
/// Like `format_duration`, but returns the target unit as well.
|
||||
|
||||
@@ -118,7 +118,8 @@ fn build_parameterized_commands<'a, T: Numeric>(
|
||||
for cmd in &command_strings {
|
||||
let name = command_names
|
||||
.get(i)
|
||||
.or_else(|| command_names.get(0)).copied();
|
||||
.or_else(|| command_names.get(0))
|
||||
.copied();
|
||||
commands.push(Command::new_parametrized(
|
||||
name,
|
||||
cmd,
|
||||
|
||||
@@ -50,6 +50,7 @@ fn get_cpu_times() -> CPUTimes {
|
||||
|
||||
const MICROSEC_PER_SEC: i64 = 1000 * 1000;
|
||||
|
||||
#[allow(clippy::useless_conversion)]
|
||||
CPUTimes {
|
||||
user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC
|
||||
+ i64::from(result.ru_utime.tv_usec),
|
||||
|
||||
@@ -30,15 +30,15 @@ impl fmt::Display for NumericType {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<NumericType> for i32 {
|
||||
fn into(self) -> NumericType {
|
||||
NumericType::Int(self)
|
||||
impl From<i32> for NumericType {
|
||||
fn from(x: i32) -> NumericType {
|
||||
NumericType::Int(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<NumericType> for Decimal {
|
||||
fn into(self) -> NumericType {
|
||||
NumericType::Decimal(self)
|
||||
impl From<Decimal> for NumericType {
|
||||
fn from(x: Decimal) -> NumericType {
|
||||
NumericType::Decimal(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +325,7 @@ pub struct BenchmarkResult {
|
||||
|
||||
impl BenchmarkResult {
|
||||
/// Create a new entry with the given values.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
command: String,
|
||||
mean: Second,
|
||||
|
||||
+4
-2
@@ -97,7 +97,8 @@ fn build_hyperfine_options<'a>(
|
||||
matches
|
||||
.value_of(param)
|
||||
.map(|n| {
|
||||
u64::from_str_radix(n, 10).map_err(|e| OptionsError::NumericParsingError(param, e))
|
||||
n.parse::<u64>()
|
||||
.map_err(|e| OptionsError::NumericParsingError(param, e))
|
||||
})
|
||||
.transpose()
|
||||
};
|
||||
@@ -270,7 +271,8 @@ fn build_commands<'a>(matches: &'a ArgMatches<'_>) -> Vec<Command<'a>> {
|
||||
'outer: loop {
|
||||
let name = command_names
|
||||
.get(i)
|
||||
.or_else(|| command_names.get(0)).copied();
|
||||
.or_else(|| command_names.get(0))
|
||||
.copied();
|
||||
i += 1;
|
||||
|
||||
let (command_index, params_indices) = index.split_first().unwrap();
|
||||
|
||||
Reference in new issue
Block a user