@@ -96,7 +96,7 @@ pub async fn handle_triage(
96
96
. clone ( )
97
97
. summarize_by_category ( & benchmark_map) ;
98
98
let mut result = String :: from ( "**Summary**:\n \n " ) ;
99
- write_summary_table ( & primary, & secondary, false , & mut result) ;
99
+ write_summary_table ( & primary, & secondary, false , true , & mut result) ;
100
100
result
101
101
}
102
102
None => String :: from ( "**ERROR**: no data found for end bound" ) ,
@@ -513,7 +513,7 @@ async fn write_triage_summary(
513
513
let link = & compare_link ( start, end) ;
514
514
write ! ( & mut result, " [(Comparison Link)]({})\n \n " , link) . unwrap ( ) ;
515
515
516
- write_summary_table ( & primary, & secondary, false , & mut result) ;
516
+ write_summary_table ( & primary, & secondary, false , true , & mut result) ;
517
517
518
518
result
519
519
}
@@ -523,17 +523,20 @@ pub fn write_summary_table(
523
523
primary : & ArtifactComparisonSummary ,
524
524
secondary : & ArtifactComparisonSummary ,
525
525
with_footnotes : bool ,
526
+ include_metric : bool ,
526
527
result : & mut String ,
527
528
) {
528
- let metric = match primary
529
- . relevant_comparisons
530
- . first ( )
531
- . or ( secondary. relevant_comparisons . first ( ) )
532
- . map ( |m| m. metric . as_str ( ) )
533
- {
534
- Some ( m) => m,
535
- None => return ,
536
- } ;
529
+ let metric = include_metric
530
+ . then ( || {
531
+ primary
532
+ . relevant_comparisons
533
+ . first ( )
534
+ . or ( secondary. relevant_comparisons . first ( ) )
535
+ . map ( |m| m. metric . as_str ( ) )
536
+ } )
537
+ . flatten ( )
538
+ // we want at least 10 spaces to accommodate "count[^2]"
539
+ . unwrap_or ( " " ) ;
537
540
538
541
fn render_stat < F : FnOnce ( ) -> Option < f64 > > ( count : usize , calculate : F ) -> String {
539
542
let value = if count > 0 { calculate ( ) } else { None } ;
@@ -637,7 +640,7 @@ pub fn write_summary_table(
637
640
// This code attempts to space the table cells evenly so that the data is
638
641
// easy to read for anyone who is viewing the Markdown source.
639
642
let column_labels = [
640
- format ! ( "({metric})" , ) ,
643
+ format ! ( "({metric})" ) ,
641
644
format ! ( "mean{}" , if with_footnotes { "[^1]" } else { "" } ) ,
642
645
"max" . to_string ( ) ,
643
646
format ! ( "count{}" , if with_footnotes { "[^2]" } else { "" } ) ,
@@ -1581,7 +1584,7 @@ mod tests {
1581
1584
let secondary = ArtifactComparisonSummary :: summarize ( secondary_comparisons) ;
1582
1585
1583
1586
let mut result = String :: new ( ) ;
1584
- write_summary_table ( & primary, & secondary, true , & mut result) ;
1587
+ write_summary_table ( & primary, & secondary, true , true , & mut result) ;
1585
1588
let header = "| (instructions:u) | mean[^1] | max | count[^2] |\n |:----------------:|:--------:|:---:|:---------:|\n " ;
1586
1589
assert_eq ! ( result, format!( "{header}{expected}" ) ) ;
1587
1590
}
0 commit comments