Skip to content

Commit

Permalink
Run 'cargo fmt'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed May 22, 2018
1 parent e6d31f5 commit 22491e2
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 32 deletions.
14 changes: 8 additions & 6 deletions src/hyperfine/app.rs
Original file line number Diff line number Diff line change
@@ -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<T>(args: T) -> ArgMatches<'static>
where
Expand Down Expand Up @@ -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.")
Expand Down
10 changes: 5 additions & 5 deletions src/hyperfine/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use std::process::Stdio;
use colored::*;
use statistical::{mean, standard_deviation};

use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};
use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second};
use hyperfine::warnings::Warnings;
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::timer::{TimerStart, TimerStop};
use hyperfine::timer::wallclocktimer::WallClockTimer;
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;

/// Results from timing a single shell command
#[derive(Debug, Default, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfine/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::num;
use std::error::Error;
use std::fmt;
use std::num;

#[derive(Debug)]
pub enum ParameterScanError {
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfine/export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions src/hyperfine/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions src/hyperfine/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod app;
pub mod benchmark;
pub mod error;
pub mod export;
pub mod format;
pub mod internal;
Expand All @@ -7,5 +9,3 @@ pub mod shell;
pub mod timer;
pub mod types;
pub mod warnings;
pub mod error;
pub mod app;
1 change: 0 additions & 1 deletion src/hyperfine/outlier_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/hyperfine/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::process::ExitStatus> {
fn run_shell_command(
stdout: Stdio,
stderr: Stdio,
command: &str,
) -> io::Result<std::process::ExitStatus> {
Command::new("sh")
.arg("-c")
.arg(command)
Expand All @@ -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<std::process::Child> {
fn run_shell_command(
stdout: Stdio,
stderr: Stdio,
command: &str,
) -> io::Result<std::process::Child> {
Command::new("cmd")
.arg("/C")
.arg(command)
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfine/timer/wallclocktimer.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/hyperfine/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// This module contains common internal types.
use std::fmt;

/// Type alias for unit of time
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfine/warnings.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::app::get_arg_matches;
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::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) -> ! {
Expand All @@ -56,8 +57,7 @@ pub fn error(message: &str) -> ! {

/// Runs the benchmark for the given commands
fn run(commands: &Vec<Command>, options: &HyperfineOptions) -> io::Result<Vec<BenchmarkResult>> {
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![];

Expand Down

0 comments on commit 22491e2

Please sign in to comment.