Skip to content

Commit 0ecc549

Browse files
committed
Optionally write footnotes for summary table
1 parent 611a1d5 commit 0ecc549

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

site/src/comparison.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async fn populate_report(
155155
.entry(confidence.is_definitely_relevant().then(|| direction))
156156
.or_default();
157157

158-
entry.push(write_summary(ctxt, comparison).await)
158+
entry.push(write_triage_summary(ctxt, comparison).await)
159159
}
160160
}
161161
}
@@ -372,7 +372,7 @@ impl ComparisonSummary {
372372
}
373373
}
374374

375-
async fn write_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> String {
375+
async fn write_triage_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> String {
376376
use std::fmt::Write;
377377
let mut result = if let Some(pr) = comparison.b.pr {
378378
let title = github::pr_title(pr).await;
@@ -393,7 +393,7 @@ async fn write_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> String {
393393
let primary = primary.unwrap_or_else(ComparisonSummary::empty);
394394
let secondary = secondary.unwrap_or_else(ComparisonSummary::empty);
395395

396-
write_summary_table(&primary, &secondary, &mut result);
396+
write_summary_table(&primary, &secondary, false, &mut result);
397397

398398
result
399399
}
@@ -402,6 +402,7 @@ async fn write_summary(ctxt: &SiteCtxt, comparison: &Comparison) -> String {
402402
pub fn write_summary_table(
403403
primary: &ComparisonSummary,
404404
secondary: &ComparisonSummary,
405+
with_footnotes: bool,
405406
result: &mut String,
406407
) {
407408
use std::fmt::Write;
@@ -421,7 +422,8 @@ pub fn write_summary_table(
421422
.unwrap();
422423
writeln!(
423424
result,
424-
"| count[^1] | {} | {} | {} | {} | {} |",
425+
"| count{} | {} | {} | {} | {} | {} |",
426+
if with_footnotes { "[^1]" } else { "" },
425427
primary.num_regressions,
426428
secondary.num_regressions,
427429
primary.num_improvements,
@@ -432,7 +434,8 @@ pub fn write_summary_table(
432434

433435
writeln!(
434436
result,
435-
"| mean[^2] | {} | {} | {} | {} | {} |",
437+
"| mean{} | {} | {} | {} | {} | {} |",
438+
if with_footnotes { "[^2]" } else { "" },
436439
render_stat(primary.num_regressions, || Some(
437440
primary.arithmetic_mean_of_regressions()
438441
)),
@@ -511,13 +514,15 @@ pub fn write_summary_table(
511514
.unwrap();
512515
}
513516

514-
writeln!(
515-
result,
516-
r#"
517+
if with_footnotes {
518+
writeln!(
519+
result,
520+
r#"
517521
[^1]: *number of relevant changes*
518522
[^2]: *the arithmetic mean of the percent change*"#
519-
)
520-
.unwrap();
523+
)
524+
.unwrap();
525+
}
521526
}
522527

523528
/// The amount of confidence we have that a comparison actually represents a real
@@ -1275,16 +1280,13 @@ fn compare_link(start: &ArtifactId, end: &ArtifactId) -> String {
12751280

12761281
#[cfg(test)]
12771282
mod tests {
1283+
use super::*;
1284+
12781285
use collector::category::Category;
12791286
use std::collections::HashSet;
12801287

12811288
use database::{ArtifactId, Profile, Scenario};
12821289

1283-
use crate::comparison::{
1284-
write_summary_table, ArtifactDescription, Comparison, ComparisonSummary,
1285-
TestResultComparison,
1286-
};
1287-
12881290
#[test]
12891291
fn summary_table_only_regressions_primary() {
12901292
check_table(
@@ -1487,7 +1489,7 @@ mod tests {
14871489
let secondary = create_summary(secondary_statistics);
14881490

14891491
let mut result = String::new();
1490-
write_summary_table(&primary, &secondary, &mut result);
1492+
write_summary_table(&primary, &secondary, true, &mut result);
14911493
assert_eq!(result, expected);
14921494
}
14931495

site/src/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ async fn categorize_benchmark(
700700
primary.unwrap_or_else(|| ComparisonSummary::empty()),
701701
secondary.unwrap_or_else(|| ComparisonSummary::empty()),
702702
);
703-
write_summary_table(&primary, &secondary, &mut result);
703+
write_summary_table(&primary, &secondary, true, &mut result);
704704
}
705705

706706
write!(result, "\n{}", DISAGREEMENT).unwrap();

0 commit comments

Comments
 (0)