Add median run time to CSV and JSON export formats
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 4a67987 · Browse files · 5 files·+21 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+21 added−1 removed
- other:+21 added−1 removed
Provenance
- Commit
fb7ded6- Tree
0746161- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
4a67987
5 files changed+21 added−1 removed
modified:src/hyperfine/export/asciidoc.rs+4 added
85 unmodified lines86 let result = BenchmarkResult::new(87 String::from("sleep 1"), // command88 0.10491992406666667, // mean89 0.00397851689425097, // stddev90+ 0.10491992406666667, // median91 0.005182013333333333, // user92 0.0, // system93 0.1003342584, // min94 0.10745223440000001, // max42 unmodified lines137 let result = BenchmarkResult::new(138 String::from("sleep 1|"), // command139 0.10491992406666667, // mean140 0.00397851689425097, // stddev141+ 0.10491992406666667, // median142 0.005182013333333333, // user143 0.0, // system144 0.1003342584, // min145 0.10745223440000001, // max29 unmodified lines175 BenchmarkResult::new(176 String::from("command | 1"),177 1.0,178 2.0,179+ 1.0,180 3.0,181 4.0,182 5.0,183 6.0,3 unmodified lines187 BenchmarkResult::new(188 String::from("command | 2"),189 11.0,190 12.0,191+ 11.0,192 13.0,193 14.0,194 15.0,195 16.0,25 unmodified linesmodified:src/hyperfine/export/markdown.rs+8 added
82 unmodified lines83 timing_results.push(BenchmarkResult::new(84 String::from("sleep 0.1"),85 0.1057, // mean86 0.0016, // std dev87+ 0.1057, // median88 0.0009, // user_mean89 0.0011, // system_mean90 0.1023, // min91 0.1080, // max4 unmodified lines96 timing_results.push(BenchmarkResult::new(97 String::from("sleep 2"),98 2.0050, // mean99 0.0020, // std dev100+ 2.0050, // median101 0.0009, // user_mean102 0.0012, // system_mean103 2.0020, // min104 2.0080, // max25 unmodified lines130 timing_results.push(BenchmarkResult::new(131 String::from("sleep 2"),132 2.0050, // mean133 0.0020, // std dev134+ 2.0050, // median135 0.0009, // user_mean136 0.0012, // system_mean137 2.0020, // min138 2.0080, // max4 unmodified lines143 timing_results.push(BenchmarkResult::new(144 String::from("sleep 0.1"),145 0.1057, // mean146 0.0016, // std dev147+ 0.1057, // median148 0.0009, // user_mean149 0.0011, // system_mean150 0.1023, // min151 0.1080, // max24 unmodified lines176 timing_results.push(BenchmarkResult::new(177 String::from("sleep 0.1"),178 0.1057, // mean179 0.0016, // std dev180+ 0.1057, // median181 0.0009, // user_mean182 0.0011, // system_mean183 0.1023, // min184 0.1080, // max4 unmodified lines189 timing_results.push(BenchmarkResult::new(190 String::from("sleep 2"),191 2.0050, // mean192 0.0020, // std dev193+ 2.0050, // median194 0.0009, // user_mean195 0.0012, // system_mean196 2.0020, // min197 2.0080, // max30 unmodified lines228 timing_results.push(BenchmarkResult::new(229 String::from("sleep 2"),230 2.0050, // mean231 0.0020, // std dev232+ 2.0050, // median233 0.0009, // user_mean234 0.0012, // system_mean235 2.0020, // min236 2.0080, // max4 unmodified lines241 timing_results.push(BenchmarkResult::new(242 String::from("sleep 0.1"),243 0.1057, // mean244 0.0016, // std dev245+ 0.1057, // median246 0.0009, // user_mean247 0.0011, // system_mean248 0.1023, // min249 0.1080, // max21 unmodified linesmodified:src/hyperfine/benchmark.rs+3 added-1 removed
1 unmodified line2 use std::io;3 use std::process::Stdio;4 5 use colored::*;6-use statistical::{mean, standard_deviation};6+use statistical::{mean, median, standard_deviation};7 8 use crate::hyperfine::format::{format_duration, format_duration_unit};9 use crate::hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};10 use crate::hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};301 unmodified lines312 // Compute statistical quantities313 let t_num = times_real.len();314 let t_mean = mean(×_real);315 let t_stddev = standard_deviation(×_real, Some(t_mean));316+ let t_median = median(×_real);317 let t_min = min(×_real);318 let t_max = max(×_real);319 320 let user_mean = mean(×_user);73 unmodified lines394 Ok(BenchmarkResult::new(395 cmd.get_shell_command(),396 t_mean,397 t_stddev,398+ t_median,399 user_mean,400 system_mean,401 t_min,402 t_max,4 unmodified linesmodified:src/hyperfine/internal.rs+1 added
123 unmodified lines124 let create_result = |name: &str, mean| BenchmarkResult {125 command: name.into(),126 mean: mean,127 stddev: 1.0,128+ median: mean,129 user: mean,130 system: 0.0,131 min: mean,132 max: mean,16 unmodified linesmodified:src/hyperfine/types.rs+5 added
157 unmodified lines158 159 /// The standard deviation of all run times160 pub stddev: Second,161 162+ /// The median run time163+ pub median: Second,164+165 /// Time spend in user space166 pub user: Second,167 168 /// Time spent in system space19 unmodified lines188 pub fn new(189 command: String,190 mean: Second,191 stddev: Second,192+ median: Second,193 user: Second,194 system: Second,195 min: Second,196 max: Second,3 unmodified lines200 BenchmarkResult {201 command,202 mean,203 stddev,204+ median,205 user,206 system,207 min,208 max,5 unmodified lines