Skip to content
Myr

Run 'cargo fmt'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent e6d31f5 · Browse files · 12 files+42 added−32 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

12 files+42 added−32 removed

  • other:+42 added−32 removed

12 files+42 added−32 removed

modified:src/hyperfine/export/mod.rs+1 added-1 removed
4 unmodified lines
5use self::csv::CsvExporter;6use self::json::JsonExporter;7use self::markdown::MarkdownExporter;89use std::io::{Result, Write};9use std::fs::File;10use std::io::{Result, Write};1112use hyperfine::types::BenchmarkResult;1314/// The desired form of exporter to use for a given file.
64 unmodified lines
modified:src/hyperfine/timer/wallclocktimer.rs+1 added-1 removed
1use std::process::Child;2use std::time::Instant;34use hyperfine::types::Second;4use hyperfine::timer::{TimerStart, TimerStop};5use hyperfine::types::Second;67pub struct WallClockTimer {8 start: Instant,9}
21 unmodified lines
modified:src/hyperfine/app.rs+8 added-6 removed
1use clap::{App, AppSettings, Arg, ArgMatches};2use std::ffi::OsString;1use atty;2use atty::Stream;3use clap::{App, AppSettings, Arg, ArgMatches};4use std::ffi::OsString;56pub fn get_arg_matches<T>(args: T) -> ArgMatches<'static>7where8 T: Iterator<Item = OsString>,
112 unmodified lines
121 .arg(122 Arg::with_name("show-output")123 .long("show-output")124 .conflicts_with("style")125 .help(125 .help("Print the stdout and stderr of the benchmark instead of suppressing it. \126 This will increase the time it takes for benchmarks to run, \127 so it should only be used for debugging purposes or \128 when trying to benchmark output speed."),126 "Print the stdout and stderr of the benchmark instead of suppressing it. \127 This will increase the time it takes for benchmarks to run, \128 so it should only be used for debugging purposes or \129 when trying to benchmark output speed.",130 ),131 )132 .help_message("Print this help message.")133 .version_message("Show version information.")134}
modified:src/hyperfine/benchmark.rs+5 added-5 removed
2 unmodified lines
34use colored::*;5use statistical::{mean, standard_deviation};67use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};8use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second};9use hyperfine::warnings::Warnings;7use hyperfine::format::{format_duration, format_duration_unit};8use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};9use hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};12use hyperfine::timer::{TimerStart, TimerStop};13use hyperfine::timer::wallclocktimer::WallClockTimer;10use hyperfine::shell::execute_and_time;11use hyperfine::timer::wallclocktimer::WallClockTimer;12use hyperfine::timer::{TimerStart, TimerStop};13use hyperfine::types::{BenchmarkResult, Command};14use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second};15use hyperfine::warnings::Warnings;1617/// Results from timing a single shell command18#[derive(Debug, Default, Copy, Clone)]19pub struct TimingResult {
320 unmodified lines
modified:src/hyperfine/error.rs+1 added-1 removed
1use std::num;1use std::error::Error;2use std::fmt;3use std::num;45#[derive(Debug)]6pub enum ParameterScanError {7 ParseIntError(num::ParseIntError),
31 unmodified lines
modified:src/hyperfine/internal.rs+4 added-2 removed
29 unmodified lines
30}3132/// A max function for f64's without NaNs33pub fn max(vals: &[f64]) -> f64 {34 *vals.iter()34 *vals35 .iter()36 .max_by(|a, b| a.partial_cmp(b).unwrap())37 .unwrap()38}3940/// A min function for f64's without NaNs41pub fn min(vals: &[f64]) -> f64 {41 *vals.iter()42 *vals43 .iter()44 .min_by(|a, b| a.partial_cmp(b).unwrap())45 .unwrap()46}47
41 unmodified lines
modified:src/hyperfine/mod.rs+2 added-2 removed
1pub mod app;2pub mod benchmark;3pub mod error;4pub mod export;5pub mod format;6pub mod internal;7pub mod outlier_detection;8pub mod shell;9pub mod timer;10pub mod types;11pub mod warnings;10pub mod error;11pub mod app;
modified:src/hyperfine/outlier_detection.rs-1 removed
2 unmodified lines
3/// References:4/// - Boris Iglewicz and David Hoaglin (1993), "Volume 16: How to Detect and Handle Outliers",5/// The ASQC Basic References in Quality Control: Statistical Techniques, Edward F. Mykytka,6/// Ph.D., Editor.77use statistical::median;89/// Minimum modified Z-score for a datapoint to be an outlier. Here, 1.4826 is a factor that10/// converts the MAD to an estimator for the standard deviation. The second factor is the number
91 unmodified lines
modified:src/hyperfine/shell.rs+10 added-2 removed
48 unmodified lines
49}5051/// Run a standard shell command52#[cfg(not(windows))]53fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result<std::process::ExitStatus> {53fn run_shell_command(54 stdout: Stdio,55 stderr: Stdio,56 command: &str,57) -> io::Result<std::process::ExitStatus> {58 Command::new("sh")59 .arg("-c")60 .arg(command)61 .stdin(Stdio::null())
3 unmodified lines
65}6667/// Run a Windows shell command using cmd.exe68#[cfg(windows)]65fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result<std::process::Child> {69fn run_shell_command(70 stdout: Stdio,71 stderr: Stdio,72 command: &str,73) -> io::Result<std::process::Child> {74 Command::new("cmd")75 .arg("/C")76 .arg(command)77 .stdin(Stdio::null())
4 unmodified lines
modified:src/hyperfine/types.rs-1 removed
1/// This module contains common internal types.22use std::fmt;34/// Type alias for unit of time5pub type Second = f64;
157 unmodified lines
modified:src/hyperfine/warnings.rs+1 added-1 removed
1use std::fmt;23use hyperfine::format::format_duration;4use hyperfine::internal::MIN_EXECUTION_TIME;5use hyperfine::types::Second;5use hyperfine::format::format_duration;67/// A list of all possible warnings8pub enum Warnings {9 FastExecutionTime,
32 unmodified lines
modified:src/main.rs+9 added-9 removed
27 unmodified lines
28#[macro_use]29extern crate approx;3031use std::cmp;32use std::error::Error;32use std::env;33use std::error::Error;34use std::io;35use std::ops::Range;3637use atty::Stream;38use colored::*;38use clap::ArgMatches;39use colored::*;4041mod hyperfine;4243use hyperfine::internal::write_benchmark_comparison;44use hyperfine::types::{BenchmarkResult, CmdFailureAction, Command, HyperfineOptions,45 OutputStyleOption};43use hyperfine::app::get_arg_matches;44use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};47use hyperfine::export::{ExportManager, ExportType};45use hyperfine::error::ParameterScanError;49use hyperfine::app::get_arg_matches;46use hyperfine::export::{ExportManager, ExportType};47use hyperfine::internal::write_benchmark_comparison;48use hyperfine::types::{49 BenchmarkResult, CmdFailureAction, Command, HyperfineOptions, OutputStyleOption,50};5152/// Print error message to stderr and terminate53pub fn error(message: &str) -> ! {54 eprintln!("{} {}", "Error:".red(), message);
1 unmodified line
56}5758/// Runs the benchmark for the given commands59fn run(commands: &Vec<Command>, options: &HyperfineOptions) -> io::Result<Vec<BenchmarkResult>> {59 let shell_spawning_time =60 mean_shell_spawning_time(&options.output_style, options.show_output)?;60 let shell_spawning_time = mean_shell_spawning_time(&options.output_style, options.show_output)?;6162 let mut timing_results = vec![];6364 // Run the benchmarks
135 unmodified lines