Skip to content
Myr

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

5 files+21 added−1 removed

modified:src/hyperfine/export/asciidoc.rs+4 added
85 unmodified lines
86 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, // max
42 unmodified lines
137 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, // max
29 unmodified lines
175 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 lines
187 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 lines
modified:src/hyperfine/export/markdown.rs+8 added
82 unmodified lines
83 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, // max
4 unmodified lines
96 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, // max
25 unmodified lines
130 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, // max
4 unmodified lines
143 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, // max
24 unmodified lines
176 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, // max
4 unmodified lines
189 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, // max
30 unmodified lines
228 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, // max
4 unmodified lines
241 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, // max
21 unmodified lines
modified:src/hyperfine/benchmark.rs+3 added-1 removed
1 unmodified line
2use std::io;3use std::process::Stdio;45use colored::*;6use statistical::{mean, standard_deviation};6use statistical::{mean, median, standard_deviation};78use crate::hyperfine::format::{format_duration, format_duration_unit};9use crate::hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};10use crate::hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};
301 unmodified lines
312 // Compute statistical quantities313 let t_num = times_real.len();314 let t_mean = mean(&times_real);315 let t_stddev = standard_deviation(&times_real, Some(t_mean));316 let t_median = median(&times_real);317 let t_min = min(&times_real);318 let t_max = max(&times_real);319320 let user_mean = mean(&times_user);
73 unmodified lines
394 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 lines
modified:src/hyperfine/internal.rs+1 added
123 unmodified lines
124 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 lines
modified:src/hyperfine/types.rs+5 added
157 unmodified lines
158159 /// The standard deviation of all run times160 pub stddev: Second,161162 /// The median run time163 pub median: Second,164165 /// Time spend in user space166 pub user: Second,167168 /// Time spent in system space
19 unmodified lines
188 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 lines
200 BenchmarkResult {201 command,202 mean,203 stddev,204 median,205 user,206 system,207 min,208 max,
5 unmodified lines