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
Provenance
- Commit
4cb86f4- Tree
25ef3fc- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
df2e671
3 files changed+14 added−8 removed
modified:src/hyperfine/export/markdown.rs+10 added-6 removed
51 unmodified lines52 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+ };61 62 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 lines115 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();116 117 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 lines163 164 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 lines213 .unwrap();214 215 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 lines266 267 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 linesmodified:src/hyperfine/internal.rs+2 added
48 unmodified lines49 pub 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 }55 56 fn compare_mean_time(l: &BenchmarkResult, r: &BenchmarkResult) -> Ordering {57 l.mean.partial_cmp(&r.mean).unwrap_or(Ordering::Equal)21 unmodified lines79 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 linesmodified:src/hyperfine/types.rs+2 added-2 removed
9 unmodified lines10 11 #[cfg(windows)]12 pub const DEFAULT_SHELL: &str = "cmd.exe";13 14-#[derive(Debug, Clone, Serialize, Copy)]14+#[derive(Debug, Clone, Serialize, Copy, PartialEq)]15 #[serde(untagged)]16 pub enum NumericType {17 Int(i32),18 Decimal(Decimal),161 unmodified lines180 }181 }182 183 /// Set of values that will be exported.184-#[derive(Debug, Default, Clone, Serialize)]184+#[derive(Debug, Default, Clone, Serialize, PartialEq)]185 pub struct BenchmarkResult {186 /// The command that was run187 pub command: String,188 58 unmodified lines