diff --git a/src/hyperfine/app.rs b/src/hyperfine/app.rs index fb7d4a1..8b94365 100644 --- a/src/hyperfine/app.rs +++ b/src/hyperfine/app.rs @@ -1,7 +1,7 @@ -use clap::{App, AppSettings, Arg, ArgMatches}; -use std::ffi::OsString; use atty; use atty::Stream; +use clap::{App, AppSettings, Arg, ArgMatches}; +use std::ffi::OsString; pub fn get_arg_matches(args: T) -> ArgMatches<'static> where @@ -122,10 +122,12 @@ fn build_app() -> App<'static, 'static> { Arg::with_name("show-output") .long("show-output") .conflicts_with("style") - .help("Print the stdout and stderr of the benchmark instead of suppressing it. \ - This will increase the time it takes for benchmarks to run, \ - so it should only be used for debugging purposes or \ - when trying to benchmark output speed."), + .help( + "Print the stdout and stderr of the benchmark instead of suppressing it. \ + This will increase the time it takes for benchmarks to run, \ + so it should only be used for debugging purposes or \ + when trying to benchmark output speed.", + ), ) .help_message("Print this help message.") .version_message("Show version information.") diff --git a/src/hyperfine/benchmark.rs b/src/hyperfine/benchmark.rs index ef1a937..5877ae4 100644 --- a/src/hyperfine/benchmark.rs +++ b/src/hyperfine/benchmark.rs @@ -4,15 +4,15 @@ use std::process::Stdio; use colored::*; use statistical::{mean, standard_deviation}; +use hyperfine::format::{format_duration, format_duration_unit}; use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME}; +use hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD}; +use hyperfine::shell::execute_and_time; +use hyperfine::timer::wallclocktimer::WallClockTimer; +use hyperfine::timer::{TimerStart, TimerStop}; +use hyperfine::types::{BenchmarkResult, Command}; use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second}; use hyperfine::warnings::Warnings; -use hyperfine::format::{format_duration, format_duration_unit}; -use hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD}; -use hyperfine::timer::{TimerStart, TimerStop}; -use hyperfine::timer::wallclocktimer::WallClockTimer; -use hyperfine::shell::execute_and_time; -use hyperfine::types::{BenchmarkResult, Command}; /// Results from timing a single shell command #[derive(Debug, Default, Copy, Clone)] diff --git a/src/hyperfine/error.rs b/src/hyperfine/error.rs index d7901e7..b66221f 100644 --- a/src/hyperfine/error.rs +++ b/src/hyperfine/error.rs @@ -1,6 +1,6 @@ -use std::num; use std::error::Error; use std::fmt; +use std::num; #[derive(Debug)] pub enum ParameterScanError { diff --git a/src/hyperfine/export/mod.rs b/src/hyperfine/export/mod.rs index 35ca48d..294188d 100644 --- a/src/hyperfine/export/mod.rs +++ b/src/hyperfine/export/mod.rs @@ -6,8 +6,8 @@ use self::csv::CsvExporter; use self::json::JsonExporter; use self::markdown::MarkdownExporter; -use std::io::{Result, Write}; use std::fs::File; +use std::io::{Result, Write}; use hyperfine::types::BenchmarkResult; diff --git a/src/hyperfine/internal.rs b/src/hyperfine/internal.rs index b3a7f95..cc5289d 100644 --- a/src/hyperfine/internal.rs +++ b/src/hyperfine/internal.rs @@ -31,14 +31,16 @@ pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> P /// A max function for f64's without NaNs pub fn max(vals: &[f64]) -> f64 { - *vals.iter() + *vals + .iter() .max_by(|a, b| a.partial_cmp(b).unwrap()) .unwrap() } /// A min function for f64's without NaNs pub fn min(vals: &[f64]) -> f64 { - *vals.iter() + *vals + .iter() .min_by(|a, b| a.partial_cmp(b).unwrap()) .unwrap() } diff --git a/src/hyperfine/mod.rs b/src/hyperfine/mod.rs index 277bada..0c7f34a 100644 --- a/src/hyperfine/mod.rs +++ b/src/hyperfine/mod.rs @@ -1,4 +1,6 @@ +pub mod app; pub mod benchmark; +pub mod error; pub mod export; pub mod format; pub mod internal; @@ -7,5 +9,3 @@ pub mod shell; pub mod timer; pub mod types; pub mod warnings; -pub mod error; -pub mod app; diff --git a/src/hyperfine/outlier_detection.rs b/src/hyperfine/outlier_detection.rs index 23e5b99..5aa4eb5 100644 --- a/src/hyperfine/outlier_detection.rs +++ b/src/hyperfine/outlier_detection.rs @@ -4,7 +4,6 @@ /// - Boris Iglewicz and David Hoaglin (1993), "Volume 16: How to Detect and Handle Outliers", /// The ASQC Basic References in Quality Control: Statistical Techniques, Edward F. Mykytka, /// Ph.D., Editor. - use statistical::median; /// Minimum modified Z-score for a datapoint to be an outlier. Here, 1.4826 is a factor that diff --git a/src/hyperfine/shell.rs b/src/hyperfine/shell.rs index 9032e3e..ddc60b2 100644 --- a/src/hyperfine/shell.rs +++ b/src/hyperfine/shell.rs @@ -50,7 +50,11 @@ pub fn execute_and_time(stdout: Stdio, stderr: Stdio, command: &str) -> io::Resu /// Run a standard shell command #[cfg(not(windows))] -fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result { +fn run_shell_command( + stdout: Stdio, + stderr: Stdio, + command: &str, +) -> io::Result { Command::new("sh") .arg("-c") .arg(command) @@ -62,7 +66,11 @@ fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result< /// Run a Windows shell command using cmd.exe #[cfg(windows)] -fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result { +fn run_shell_command( + stdout: Stdio, + stderr: Stdio, + command: &str, +) -> io::Result { Command::new("cmd") .arg("/C") .arg(command) diff --git a/src/hyperfine/timer/wallclocktimer.rs b/src/hyperfine/timer/wallclocktimer.rs index c39d2f0..3780ecb 100644 --- a/src/hyperfine/timer/wallclocktimer.rs +++ b/src/hyperfine/timer/wallclocktimer.rs @@ -1,8 +1,8 @@ use std::process::Child; use std::time::Instant; -use hyperfine::types::Second; use hyperfine::timer::{TimerStart, TimerStop}; +use hyperfine::types::Second; pub struct WallClockTimer { start: Instant, diff --git a/src/hyperfine/types.rs b/src/hyperfine/types.rs index 66c86a9..2835360 100644 --- a/src/hyperfine/types.rs +++ b/src/hyperfine/types.rs @@ -1,5 +1,4 @@ /// This module contains common internal types. - use std::fmt; /// Type alias for unit of time diff --git a/src/hyperfine/warnings.rs b/src/hyperfine/warnings.rs index d7520ad..7032ed4 100644 --- a/src/hyperfine/warnings.rs +++ b/src/hyperfine/warnings.rs @@ -1,8 +1,8 @@ use std::fmt; +use hyperfine::format::format_duration; use hyperfine::internal::MIN_EXECUTION_TIME; use hyperfine::types::Second; -use hyperfine::format::format_duration; /// A list of all possible warnings pub enum Warnings { diff --git a/src/main.rs b/src/main.rs index bdd908f..692235e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,24 +29,25 @@ cfg_if! { extern crate approx; use std::cmp; -use std::error::Error; use std::env; +use std::error::Error; use std::io; use std::ops::Range; use atty::Stream; -use colored::*; use clap::ArgMatches; +use colored::*; mod hyperfine; -use hyperfine::internal::write_benchmark_comparison; -use hyperfine::types::{BenchmarkResult, CmdFailureAction, Command, HyperfineOptions, - OutputStyleOption}; -use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark}; -use hyperfine::export::{ExportManager, ExportType}; -use hyperfine::error::ParameterScanError; use hyperfine::app::get_arg_matches; +use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark}; +use hyperfine::error::ParameterScanError; +use hyperfine::export::{ExportManager, ExportType}; +use hyperfine::internal::write_benchmark_comparison; +use hyperfine::types::{ + BenchmarkResult, CmdFailureAction, Command, HyperfineOptions, OutputStyleOption, +}; /// Print error message to stderr and terminate pub fn error(message: &str) -> ! { @@ -56,8 +57,7 @@ pub fn error(message: &str) -> ! { /// Runs the benchmark for the given commands fn run(commands: &Vec, options: &HyperfineOptions) -> io::Result> { - let shell_spawning_time = - mean_shell_spawning_time(&options.output_style, options.show_output)?; + let shell_spawning_time = mean_shell_spawning_time(&options.output_style, options.show_output)?; let mut timing_results = vec![];