Skip to content

Commit

Permalink
Add relative speed to markdown export, closes #225
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Oct 13, 2019
1 parent 92e59c3 commit df2e671
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/hyperfine/export/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ fn add_table_row(dest: &mut Vec<u8>, entry: &BenchmarkResultWithRelativeSpeed, u
let min_str = format_duration_value(result.min, Some(unit)).0;
let max_str = format_duration_value(result.max, Some(unit)).0;
let rel_str = format!("{:.2}", entry.relative_speed);
let rel_stddev_str = format!("{:.2}", entry.relative_speed_stddev);

dest.extend(
format!(
"| `{command}` | {mean} ± {stddev} | {min} | {max} | {rel} |\n",
"| `{command}` | {mean} ± {stddev} | {min} | {max} | {rel} ± {rel_stddev} |\n",
command = result.command.replace("|", "\\|"),
mean = mean_str,
stddev = stddev_str,
min = min_str,
max = max_str,
rel = rel_str,
rel_stddev = rel_stddev_str,
)
.as_bytes(),
);
Expand Down Expand Up @@ -110,8 +112,8 @@ fn test_markdown_format_ms() {

let formatted_expected = format!(
"{}\
| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |
| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 |
| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 ± 0.02 |
| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |
",
table_header("ms".to_string())
);
Expand Down Expand Up @@ -157,8 +159,8 @@ fn test_markdown_format_s() {

let formatted_expected = format!(
"{}\
| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 |
| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |
| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |
| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 ± 0.02 |
",
table_header("s".to_string())
);
Expand Down Expand Up @@ -208,8 +210,8 @@ fn test_markdown_format_time_unit_s() {

let formatted_expected = format!(
"{}\
| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |
| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 |
| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 ± 0.02 |
| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |
",
table_header("s".to_string())
);
Expand Down Expand Up @@ -260,8 +262,8 @@ fn test_markdown_format_time_unit_ms() {

let formatted_expected = format!(
"{}\
| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 |
| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |
| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |
| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 ± 0.02 |
",
table_header("ms".to_string())
);
Expand Down

0 comments on commit df2e671

Please sign in to comment.