From 9df6174bc29e0407bbbf769295121db9844a06d7 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 24 Aug 2021 21:33:48 +0200 Subject: [PATCH] Re-order imports --- src/app.rs | 3 ++- src/benchmark_result.rs | 3 ++- src/command.rs | 2 +- src/error.rs | 3 ++- src/export/asciidoc.rs | 5 ++--- src/export/csv.rs | 9 ++++----- src/export/json.rs | 8 ++++---- src/export/markdown.rs | 5 ++--- src/export/mod.rs | 6 +++--- src/internal.rs | 6 +++--- src/options.rs | 2 +- src/outlier_detection.rs | 13 +++++++------ src/timer/unix_timer.rs | 6 +++--- src/timer/windows_timer.rs | 14 +++++++------- src/types.rs | 2 +- src/units.rs | 2 +- 16 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1573f13..3f995fc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,6 +1,7 @@ +use std::ffi::OsString; + use atty::Stream; use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; -use std::ffi::OsString; pub fn get_arg_matches(args: I) -> ArgMatches<'static> where diff --git a/src/benchmark_result.rs b/src/benchmark_result.rs index f7a1664..b47bbfd 100644 --- a/src/benchmark_result.rs +++ b/src/benchmark_result.rs @@ -1,6 +1,7 @@ -use serde::Serialize; use std::collections::BTreeMap; +use serde::Serialize; + use crate::units::Second; /// Set of values that will be exported. diff --git a/src/command.rs b/src/command.rs index 6a14337..b6d03b5 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::fmt; -use super::types::ParameterValue; +use crate::types::ParameterValue; /// A command that should be benchmarked. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/src/error.rs b/src/error.rs index 4b4d0e0..9257790 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,10 @@ -use rust_decimal::Error as DecimalError; use std::error::Error; use std::fmt; use std::num; use std::num::ParseIntError; +use rust_decimal::Error as DecimalError; + #[derive(Debug)] pub enum ParameterScanError { ParseIntError(num::ParseIntError), diff --git a/src/export/asciidoc.rs b/src/export/asciidoc.rs index bec0177..8afafa9 100644 --- a/src/export/asciidoc.rs +++ b/src/export/asciidoc.rs @@ -1,11 +1,10 @@ -use super::Exporter; +use std::io::Result; +use super::Exporter; use crate::benchmark_result::BenchmarkResult; use crate::format::format_duration_value; use crate::units::Unit; -use std::io::Result; - #[derive(Default)] pub struct AsciidocExporter {} diff --git a/src/export/csv.rs b/src/export/csv.rs index b188487..a954a93 100644 --- a/src/export/csv.rs +++ b/src/export/csv.rs @@ -1,13 +1,12 @@ -use super::Exporter; - -use crate::benchmark_result::BenchmarkResult; -use crate::units::Unit; - use std::borrow::Cow; use std::io::{Error, ErrorKind, Result}; use csv::WriterBuilder; +use super::Exporter; +use crate::benchmark_result::BenchmarkResult; +use crate::units::Unit; + #[derive(Default)] pub struct CsvExporter {} diff --git a/src/export/json.rs b/src/export/json.rs index babef3d..aea96ea 100644 --- a/src/export/json.rs +++ b/src/export/json.rs @@ -1,12 +1,12 @@ -use super::Exporter; -use crate::benchmark_result::BenchmarkResult; -use crate::units::Unit; - use std::io::{Error, ErrorKind, Result}; use serde::*; use serde_json::to_vec_pretty; +use super::Exporter; +use crate::benchmark_result::BenchmarkResult; +use crate::units::Unit; + #[derive(Serialize, Debug)] struct HyperfineSummary<'a> { results: &'a [BenchmarkResult], diff --git a/src/export/markdown.rs b/src/export/markdown.rs index 4b3652a..e466ce3 100644 --- a/src/export/markdown.rs +++ b/src/export/markdown.rs @@ -1,12 +1,11 @@ -use super::Exporter; +use std::io::{Error, ErrorKind, Result}; +use super::Exporter; use crate::benchmark_result::BenchmarkResult; use crate::format::format_duration_value; use crate::internal::{compute_relative_speed, BenchmarkResultWithRelativeSpeed}; use crate::units::Unit; -use std::io::{Error, ErrorKind, Result}; - #[derive(Default)] pub struct MarkdownExporter {} diff --git a/src/export/mod.rs b/src/export/mod.rs index 7fc0e4a..aa27185 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -1,3 +1,6 @@ +use std::fs::{File, OpenOptions}; +use std::io::{Result, Write}; + mod asciidoc; mod csv; mod json; @@ -8,9 +11,6 @@ use self::csv::CsvExporter; use self::json::JsonExporter; use self::markdown::MarkdownExporter; -use std::fs::{File, OpenOptions}; -use std::io::{Result, Write}; - use crate::benchmark_result::BenchmarkResult; use crate::units::Unit; diff --git a/src/internal.rs b/src/internal.rs index b2833bf..1d7f14b 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -1,3 +1,6 @@ +use std::cmp::Ordering; +use std::iter::Iterator; + use colored::*; use indicatif::{ProgressBar, ProgressStyle}; @@ -5,9 +8,6 @@ use crate::benchmark_result::BenchmarkResult; use crate::options::OutputStyleOption; use crate::units::{Scalar, Second}; -use std::cmp::Ordering; -use std::iter::Iterator; - /// Threshold for warning about fast execution time pub const MIN_EXECUTION_TIME: Second = 5e-3; diff --git a/src/options.rs b/src/options.rs index 44abf7c..2ffaccd 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,4 +1,4 @@ -use super::units::{Second, Unit}; +use crate::units::{Second, Unit}; #[cfg(not(windows))] pub const DEFAULT_SHELL: &str = "sh"; diff --git a/src/outlier_detection.rs b/src/outlier_detection.rs index fdf2df6..270e522 100644 --- a/src/outlier_detection.rs +++ b/src/outlier_detection.rs @@ -1,9 +1,10 @@ -/// A module for statistical outlier detection. -/// -/// References: -/// - 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. +//! A module for statistical outlier detection. +//! +//! References: +//! - 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/timer/unix_timer.rs b/src/timer/unix_timer.rs index 2450f2f..354a010 100644 --- a/src/timer/unix_timer.rs +++ b/src/timer/unix_timer.rs @@ -1,12 +1,12 @@ #![cfg(not(windows))] +use std::mem; +use std::process::Child; + use super::internal::{CPUInterval, CPUTimes}; use crate::timer::{TimerStart, TimerStop}; use crate::units::Second; -use std::mem; -use std::process::Child; - pub fn get_cpu_timer() -> Box> { Box::new(CPUTimer::start()) } diff --git a/src/timer/windows_timer.rs b/src/timer/windows_timer.rs index 117cc2c..0add8c3 100644 --- a/src/timer/windows_timer.rs +++ b/src/timer/windows_timer.rs @@ -1,16 +1,16 @@ #![cfg(windows)] -use super::internal::CPUTimes; -use crate::timer::{TimerStart, TimerStop}; -use crate::units::Second; - -use winapi::um::processthreadsapi::GetProcessTimes; -use winapi::um::winnt::HANDLE; - use std::mem; use std::os::windows::io::{AsRawHandle, RawHandle}; use std::process::Child; +use winapi::um::processthreadsapi::GetProcessTimes; +use winapi::um::winnt::HANDLE; + +use super::internal::CPUTimes; +use crate::timer::{TimerStart, TimerStop}; +use crate::units::Second; + const HUNDRED_NS_PER_MS: i64 = 10; pub fn get_cpu_timer(process: &Child) -> Box> { diff --git a/src/types.rs b/src/types.rs index 25417a5..1dc6863 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,9 +1,9 @@ -use serde::Serialize; use std::convert::TryFrom; use std::fmt; use rust_decimal::prelude::ToPrimitive; use rust_decimal::Decimal; +use serde::Serialize; #[derive(Debug, Clone, Serialize, Copy, PartialEq, Eq)] #[serde(untagged)] diff --git a/src/units.rs b/src/units.rs index 09364ea..5939e1d 100644 --- a/src/units.rs +++ b/src/units.rs @@ -1,4 +1,4 @@ -/// This module contains common units. +//! This module contains common units. pub type Scalar = f64;