@@ -49,21 +49,29 @@ pub async fn handle_triage(
49
49
let mut num_comparisons = 0 ;
50
50
let metric = Metric :: InstructionsUser ;
51
51
let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
52
- loop {
53
- let comparison =
54
- match compare_given_commits ( before, next. clone ( ) , metric, ctxt, & master_commits)
55
- . await
56
- . map_err ( |e| format ! ( "error comparing commits: {}" , e) ) ?
57
- {
58
- Some ( c) => c,
59
- None => {
60
- log:: info!(
61
- "No data found for end bound {:?}. Ending comparison..." ,
62
- next
63
- ) ;
64
- break ;
65
- }
66
- } ;
52
+ // Track whether we are on the known last iteration
53
+ let mut last_iteration = false ;
54
+
55
+ let end = loop {
56
+ let comparison = match compare_given_commits (
57
+ before. clone ( ) ,
58
+ next. clone ( ) ,
59
+ metric,
60
+ ctxt,
61
+ & master_commits,
62
+ )
63
+ . await
64
+ . map_err ( |e| format ! ( "error comparing commits: {}" , e) ) ?
65
+ {
66
+ Some ( c) => c,
67
+ None => {
68
+ log:: info!(
69
+ "No data found for end bound {:?}. Ending comparison..." ,
70
+ next
71
+ ) ;
72
+ break before;
73
+ }
74
+ } ;
67
75
num_comparisons += 1 ;
68
76
log:: info!(
69
77
"Comparing {} to {}" ,
@@ -74,17 +82,25 @@ pub async fn handle_triage(
74
82
// handle results of comparison
75
83
populate_report ( & comparison, & benchmark_map, & mut report) . await ;
76
84
77
- // Check that there is a next commit and that the
78
- // after commit is not equal to `end`
85
+ // If we already know this is the last iteration, we can stop
86
+ if last_iteration {
87
+ break before;
88
+ }
89
+
90
+ // Decide whether to keep doing comparisons or not
79
91
match comparison. next ( & master_commits) . map ( Bound :: Commit ) {
80
- Some ( n) if Some ( & next) != end. as_ref ( ) => {
92
+ // There is a next commit, and it is not the end bound.
93
+ // We keep doing comparisons...
94
+ Some ( n) => {
81
95
before = next;
96
+ // The next iteration is the last if the next bound is equal to the end bound
97
+ last_iteration = n != end;
82
98
next = n;
83
99
}
84
- _ => break ,
100
+ // There is no next commit so we stop.
101
+ None => break before,
85
102
}
86
- }
87
- let end = end. unwrap_or ( next) ;
103
+ } ;
88
104
89
105
// Summarize the entire triage from start commit to end commit
90
106
let summary =
0 commit comments