Skip to content

Commit 9909bdc

Browse files
committed
Show mean of primary/secondary results in GitHub summary comment tooltip
1 parent 90415c8 commit 9909bdc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

site/src/github/comparison_summary.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,25 @@ fn write_metric_summary(
324324
write_summary_table(&primary, &secondary, false, message);
325325
}
326326
DefaultMetricVisibility::Hidden => {
327+
let format_tooltip_summary =
328+
|buffer: &mut Vec<String>, label: &str, summary: &ArtifactComparisonSummary| {
329+
if summary.is_relevant() {
330+
buffer.push(format!(
331+
"{label} {:.1}%",
332+
summary.arithmetic_mean_of_changes()
333+
));
334+
}
335+
};
336+
337+
// At this point, we know that at least one of primary or secondary are relevant
338+
let mut results = vec![];
339+
format_tooltip_summary(&mut results, "primary", &primary);
340+
format_tooltip_summary(&mut results, "secondary", &secondary);
341+
342+
let tooltip = format!("Results ({})", results.join(", "));
343+
327344
// `<details>` means it is hidden, requiring a click to reveal.
328-
message.push_str("<details>\n<summary>Results</summary>\n\n");
345+
message.push_str(&format!("<details>\n<summary>{tooltip}</summary>\n\n"));
329346
message.push_str(
330347
"This is a less reliable metric that may be of interest but was not \
331348
used to determine the overall result at the top of this comment.\n\n",

0 commit comments

Comments
 (0)