mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +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 {
|
Ok(TimingResult {
|
||||||
time_real: mean(×_real),
|
time_real: mean(×_real),
|
||||||
@@ -276,9 +280,13 @@ pub fn run_benchmark(
|
|||||||
options.failure_action,
|
options.failure_action,
|
||||||
None,
|
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)
|
// Set up progress bar (and spinner for initial measurement)
|
||||||
@@ -331,8 +339,12 @@ pub fn run_benchmark(
|
|||||||
all_succeeded = all_succeeded && success;
|
all_succeeded = all_succeeded && success;
|
||||||
|
|
||||||
// Re-configure the progress bar
|
// 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() {
|
||||||
if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }
|
bar.set_length(count)
|
||||||
|
}
|
||||||
|
if let Some(bar) = progress_bar.as_ref() {
|
||||||
|
bar.inc(1)
|
||||||
|
}
|
||||||
|
|
||||||
// Gather statistics
|
// Gather statistics
|
||||||
for _ in 0..count_remaining {
|
for _ in 0..count_remaining {
|
||||||
@@ -343,8 +355,9 @@ pub fn run_benchmark(
|
|||||||
format!("Current estimate: {}", mean.to_string().green())
|
format!("Current estimate: {}", mean.to_string().green())
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(bar) = progress_bar
|
if let Some(bar) = progress_bar.as_ref() {
|
||||||
.as_ref() { bar.set_message(msg.to_owned()) }
|
bar.set_message(msg.to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
let (res, status) = time_shell_command(
|
let (res, status) = time_shell_command(
|
||||||
&options.shell,
|
&options.shell,
|
||||||
@@ -362,10 +375,14 @@ pub fn run_benchmark(
|
|||||||
|
|
||||||
all_succeeded = all_succeeded && success;
|
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
|
// Compute statistical quantities
|
||||||
let t_num = times_real.len();
|
let t_num = times_real.len();
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ impl Exporter for CsvExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for res in results {
|
for res in results {
|
||||||
let mut fields = Vec::new();
|
let mut fields = vec![Cow::Borrowed(res.command.as_bytes())];
|
||||||
fields.push(Cow::Borrowed(res.command.as_bytes()));
|
|
||||||
for f in &[
|
for f in &[
|
||||||
res.mean, res.stddev, res.median, res.user, res.system, res.min, res.max,
|
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
|
/// 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.
|
/// `Some(target_unit)`. If `unit` is `None`, it will be determined automatically.
|
||||||
pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {
|
pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {
|
||||||
match format_duration_unit(duration, unit) {
|
let (duration_fmt, _) = format_duration_unit(duration, unit);
|
||||||
(duration_fmt, _) => duration_fmt,
|
duration_fmt
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `format_duration`, but returns the target unit as well.
|
/// 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 {
|
for cmd in &command_strings {
|
||||||
let name = command_names
|
let name = command_names
|
||||||
.get(i)
|
.get(i)
|
||||||
.or_else(|| command_names.get(0)).copied();
|
.or_else(|| command_names.get(0))
|
||||||
|
.copied();
|
||||||
commands.push(Command::new_parametrized(
|
commands.push(Command::new_parametrized(
|
||||||
name,
|
name,
|
||||||
cmd,
|
cmd,
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ fn get_cpu_times() -> CPUTimes {
|
|||||||
|
|
||||||
const MICROSEC_PER_SEC: i64 = 1000 * 1000;
|
const MICROSEC_PER_SEC: i64 = 1000 * 1000;
|
||||||
|
|
||||||
|
#[allow(clippy::useless_conversion)]
|
||||||
CPUTimes {
|
CPUTimes {
|
||||||
user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC
|
user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC
|
||||||
+ i64::from(result.ru_utime.tv_usec),
|
+ i64::from(result.ru_utime.tv_usec),
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ impl fmt::Display for NumericType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<NumericType> for i32 {
|
impl From<i32> for NumericType {
|
||||||
fn into(self) -> NumericType {
|
fn from(x: i32) -> NumericType {
|
||||||
NumericType::Int(self)
|
NumericType::Int(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<NumericType> for Decimal {
|
impl From<Decimal> for NumericType {
|
||||||
fn into(self) -> NumericType {
|
fn from(x: Decimal) -> NumericType {
|
||||||
NumericType::Decimal(self)
|
NumericType::Decimal(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +325,7 @@ pub struct BenchmarkResult {
|
|||||||
|
|
||||||
impl BenchmarkResult {
|
impl BenchmarkResult {
|
||||||
/// Create a new entry with the given values.
|
/// Create a new entry with the given values.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
command: String,
|
command: String,
|
||||||
mean: Second,
|
mean: Second,
|
||||||
|
|||||||
+4
-2
@@ -97,7 +97,8 @@ fn build_hyperfine_options<'a>(
|
|||||||
matches
|
matches
|
||||||
.value_of(param)
|
.value_of(param)
|
||||||
.map(|n| {
|
.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()
|
.transpose()
|
||||||
};
|
};
|
||||||
@@ -270,7 +271,8 @@ fn build_commands<'a>(matches: &'a ArgMatches<'_>) -> Vec<Command<'a>> {
|
|||||||
'outer: loop {
|
'outer: loop {
|
||||||
let name = command_names
|
let name = command_names
|
||||||
.get(i)
|
.get(i)
|
||||||
.or_else(|| command_names.get(0)).copied();
|
.or_else(|| command_names.get(0))
|
||||||
|
.copied();
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|
||||||
let (command_index, params_indices) = index.split_first().unwrap();
|
let (command_index, params_indices) = index.split_first().unwrap();
|
||||||
|
|||||||
Reference in new issue
Block a user