Skip to content

Commit 7b53340

Browse files
authored
Merge pull request #886 from rylev/github-perf-labels
Change GitHub comment output depending on perf categorization
2 parents 1bf6662 + 90e6eb7 commit 7b53340

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

site/src/github.rs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::api::{github, ServerResult};
2+
use crate::comparison::{ComparisonSummary, Direction};
23
use crate::load::{Config, InputData, TryCommit};
34
use anyhow::Context as _;
45
use hashbrown::HashSet;
@@ -631,7 +632,11 @@ pub async fn post_finished(data: &InputData) {
631632
"https://perf.rust-lang.org/compare.html?start={}&end={}",
632633
commit.parent_sha, commit.sha
633634
);
634-
let summary = categorize_benchmark(&commit, data).await;
635+
let (summary, direction) = categorize_benchmark(&commit, data).await;
636+
let label = match direction {
637+
Some(Direction::Regression | Direction::Mixed) => "+perf-regression",
638+
Some(Direction::Improvement) | None => "-perf-regression",
639+
};
635640
post_comment(
636641
&data.config,
637642
commit.pr,
@@ -651,16 +656,19 @@ non-neutral **do not** roll this PR up -- it will mask other \
651656
regressions or improvements in the roll up.
652657
653658
@bors rollup=never
654-
@rustbot label: +S-waiting-on-review -S-waiting-on-perf",
655-
commit.sha, comparison_url, summary
659+
@rustbot label: +S-waiting-on-review -S-waiting-on-perf {}",
660+
commit.sha, comparison_url, summary, label
656661
),
657662
)
658663
.await;
659664
}
660665
}
661666
}
662667

663-
async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData) -> String {
668+
async fn categorize_benchmark(
669+
commit: &database::QueuedCommit,
670+
data: &InputData,
671+
) -> (String, Option<Direction>) {
664672
let comparison = match crate::comparison::compare(
665673
collector::Bound::Commit(commit.parent_sha.clone()),
666674
collector::Bound::Commit(commit.sha.clone()),
@@ -670,25 +678,26 @@ async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData)
670678
.await
671679
{
672680
Ok(Some(c)) => c,
673-
_ => return String::from("ERROR categorizing benchmark run!"),
681+
_ => return (String::from("ERROR categorizing benchmark run!"), None),
674682
};
675683
const DISAGREEMENT: &str = "If you disagree with this performance assessment, \
676684
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
677-
let (summary, direction) =
678-
match crate::comparison::ComparisonSummary::summarize_comparison(&comparison) {
679-
Some(s) if s.direction().is_some() => {
680-
let direction = s.direction().unwrap();
681-
(s, direction)
682-
}
683-
_ => {
684-
return format!(
685+
let (summary, direction) = match ComparisonSummary::summarize_comparison(&comparison) {
686+
Some(s) if s.direction().is_some() => {
687+
let direction = s.direction().unwrap();
688+
(s, direction)
689+
}
690+
_ => {
691+
return (
692+
format!(
685693
"This benchmark run did not return any significant changes.\n\n{}",
686694
DISAGREEMENT
687-
)
688-
}
689-
};
695+
),
696+
None,
697+
)
698+
}
699+
};
690700

691-
use crate::comparison::Direction;
692701
let category = match direction {
693702
Direction::Improvement => "improvements 🎉",
694703
Direction::Regression => "regressions 😿",
@@ -703,5 +712,5 @@ async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData)
703712
change.summary_line(&mut result, None)
704713
}
705714
write!(result, "\n{}", DISAGREEMENT).unwrap();
706-
result
715+
(result, Some(direction))
707716
}

0 commit comments

Comments
 (0)