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
Provenance
- Commit
22491e2- Tree
ac1b0ee- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
e6d31f5
12 files changed+42 added−32 removed
modified:src/hyperfine/export/mod.rs+1 added-1 removed
4 unmodified lines5 use self::csv::CsvExporter;6 use self::json::JsonExporter;7 use self::markdown::MarkdownExporter;8 9-use std::io::{Result, Write};9 use std::fs::File;10+use std::io::{Result, Write};11 12 use hyperfine::types::BenchmarkResult;13 14 /// The desired form of exporter to use for a given file.64 unmodified linesmodified:src/hyperfine/timer/wallclocktimer.rs+1 added-1 removed
1 use std::process::Child;2 use std::time::Instant;3 4-use hyperfine::types::Second;4 use hyperfine::timer::{TimerStart, TimerStop};5+use hyperfine::types::Second;6 7 pub struct WallClockTimer {8 start: Instant,9 }21 unmodified linesmodified:src/hyperfine/app.rs+8 added-6 removed
1-use clap::{App, AppSettings, Arg, ArgMatches};2-use std::ffi::OsString;1 use atty;2 use atty::Stream;3+use clap::{App, AppSettings, Arg, ArgMatches};4+use std::ffi::OsString;5 6 pub fn get_arg_matches<T>(args: T) -> ArgMatches<'static>7 where8 T: Iterator<Item = OsString>,112 unmodified lines121 .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 lines3 4 use colored::*;5 use statistical::{mean, standard_deviation};6 7-use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};8-use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second};9-use hyperfine::warnings::Warnings;7 use hyperfine::format::{format_duration, format_duration_unit};8+use hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};9 use hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};12-use hyperfine::timer::{TimerStart, TimerStop};13-use hyperfine::timer::wallclocktimer::WallClockTimer;10 use hyperfine::shell::execute_and_time;11+use hyperfine::timer::wallclocktimer::WallClockTimer;12+use hyperfine::timer::{TimerStart, TimerStop};13 use hyperfine::types::{BenchmarkResult, Command};14+use hyperfine::types::{CmdFailureAction, HyperfineOptions, OutputStyleOption, Second};15+use hyperfine::warnings::Warnings;16 17 /// Results from timing a single shell command18 #[derive(Debug, Default, Copy, Clone)]19 pub struct TimingResult {320 unmodified linesmodified:src/hyperfine/error.rs+1 added-1 removed
1-use std::num;1 use std::error::Error;2 use std::fmt;3+use std::num;4 5 #[derive(Debug)]6 pub enum ParameterScanError {7 ParseIntError(num::ParseIntError),31 unmodified linesmodified:src/hyperfine/internal.rs+4 added-2 removed
29 unmodified lines30 }31 32 /// A max function for f64's without NaNs33 pub fn max(vals: &[f64]) -> f64 {34- *vals.iter()34+ *vals35+ .iter()36 .max_by(|a, b| a.partial_cmp(b).unwrap())37 .unwrap()38 }39 40 /// A min function for f64's without NaNs41 pub 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 linesmodified:src/hyperfine/mod.rs+2 added-2 removed
1+pub mod app;2 pub mod benchmark;3+pub mod error;4 pub mod export;5 pub mod format;6 pub mod internal;7 pub mod outlier_detection;8 pub mod shell;9 pub mod timer;10 pub mod types;11 pub mod warnings;10-pub mod error;11-pub mod app;modified:src/hyperfine/outlier_detection.rs-1 removed
2 unmodified lines3 /// 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.7-7 use statistical::median;8 9 /// 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 number91 unmodified linesmodified:src/hyperfine/shell.rs+10 added-2 removed
48 unmodified lines49 }50 51 /// Run a standard shell command52 #[cfg(not(windows))]53-fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result<std::process::ExitStatus> {53+fn 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 lines65 }66 67 /// Run a Windows shell command using cmd.exe68 #[cfg(windows)]65-fn run_shell_command(stdout: Stdio, stderr: Stdio, command: &str) -> io::Result<std::process::Child> {69+fn 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 linesmodified:src/hyperfine/types.rs-1 removed
1 /// This module contains common internal types.2-2 use std::fmt;3 4 /// Type alias for unit of time5 pub type Second = f64;157 unmodified linesmodified:src/hyperfine/warnings.rs+1 added-1 removed
1 use std::fmt;2 3+use hyperfine::format::format_duration;4 use hyperfine::internal::MIN_EXECUTION_TIME;5 use hyperfine::types::Second;5-use hyperfine::format::format_duration;6 7 /// A list of all possible warnings8 pub enum Warnings {9 FastExecutionTime,32 unmodified linesmodified:src/main.rs+9 added-9 removed
27 unmodified lines28 #[macro_use]29 extern crate approx;30 31 use std::cmp;32-use std::error::Error;32 use std::env;33+use std::error::Error;34 use std::io;35 use std::ops::Range;36 37 use atty::Stream;38-use colored::*;38 use clap::ArgMatches;39+use colored::*;40 41 mod hyperfine;42 43-use hyperfine::internal::write_benchmark_comparison;44-use hyperfine::types::{BenchmarkResult, CmdFailureAction, Command, HyperfineOptions,45- OutputStyleOption};43+use hyperfine::app::get_arg_matches;44 use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};47-use hyperfine::export::{ExportManager, ExportType};45 use hyperfine::error::ParameterScanError;49-use hyperfine::app::get_arg_matches;46+use hyperfine::export::{ExportManager, ExportType};47+use hyperfine::internal::write_benchmark_comparison;48+use hyperfine::types::{49+ BenchmarkResult, CmdFailureAction, Command, HyperfineOptions, OutputStyleOption,50+};51 52 /// Print error message to stderr and terminate53 pub fn error(message: &str) -> ! {54 eprintln!("{} {}", "Error:".red(), message);1 unmodified line56 }57 58 /// Runs the benchmark for the given commands59 fn 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)?;61 62 let mut timing_results = vec![];63 64 // Run the benchmarks135 unmodified lines