Skip to content
Myr

Do not show relative stddev for fastest entry

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 df2e671 · Browse files · 3 files+14 added−8 removed
This commit

State

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

Diff stats

3 files+14 added−8 removed

  • other:+14 added−8 removed

3 files+14 added−8 removed

modified:src/hyperfine/export/markdown.rs+10 added-6 removed
51 unmodified lines
52 let stddev_str = format_duration_value(result.stddev, Some(unit)).0;53 let min_str = format_duration_value(result.min, Some(unit)).0;54 let max_str = format_duration_value(result.max, Some(unit)).0;55 let rel_str = format!("{:.2}", entry.relative_speed);56 let rel_stddev_str = format!("{:.2}", entry.relative_speed_stddev);56 let rel_stddev_str = if entry.is_fastest {57 "".into()58 } else {59 format!(" ± {:.2}", entry.relative_speed_stddev)60 };6162 dest.extend(63 format!(60 "| `{command}` | {mean} ± {stddev} | {min} | {max} | {rel} ± {rel_stddev} |\n",64 "| `{command}` | {mean} ± {stddev} | {min} | {max} | {rel}{rel_stddev} |\n",65 command = result.command.replace("|", "\\|"),66 mean = mean_str,67 stddev = stddev_str,68 min = min_str,
46 unmodified lines
115 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();116117 let formatted_expected = format!(118 "{}\115| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 ± 0.02 |119| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |120| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |121",122 table_header("ms".to_string())123 );
39 unmodified lines
163164 let formatted_expected = format!(165 "{}\166| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |163| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 ± 0.02 |167| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |168",169 table_header("s".to_string())170 );171
41 unmodified lines
213 .unwrap();214215 let formatted_expected = format!(216 "{}\213| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 ± 0.02 |217| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |218| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |219",220 table_header("s".to_string())221 );
44 unmodified lines
266267 let formatted_expected = format!(268 "{}\269| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |266| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 ± 0.02 |270| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |271",272 table_header("ms".to_string())273 );274
2 unmodified lines
modified:src/hyperfine/internal.rs+2 added
48 unmodified lines
49pub struct BenchmarkResultWithRelativeSpeed<'a> {50 pub result: &'a BenchmarkResult,51 pub relative_speed: Scalar,52 pub relative_speed_stddev: Scalar,53 pub is_fastest: bool,54}5556fn compare_mean_time(l: &BenchmarkResult, r: &BenchmarkResult) -> Ordering {57 l.mean.partial_cmp(&r.mean).unwrap_or(Ordering::Equal)
21 unmodified lines
79 BenchmarkResultWithRelativeSpeed {80 result,81 relative_speed: ratio,82 relative_speed_stddev: ratio_stddev,83 is_fastest: result == fastest,84 }85 })86 .collect()87}
63 unmodified lines
modified:src/hyperfine/types.rs+2 added-2 removed
9 unmodified lines
1011#[cfg(windows)]12pub const DEFAULT_SHELL: &str = "cmd.exe";1314#[derive(Debug, Clone, Serialize, Copy)]14#[derive(Debug, Clone, Serialize, Copy, PartialEq)]15#[serde(untagged)]16pub enum NumericType {17 Int(i32),18 Decimal(Decimal),
161 unmodified lines
180 }181}182183/// Set of values that will be exported.184#[derive(Debug, Default, Clone, Serialize)]184#[derive(Debug, Default, Clone, Serialize, PartialEq)]185pub struct BenchmarkResult {186 /// The command that was run187 pub command: String,188
58 unmodified lines