@@ -166,12 +166,10 @@ async fn populate_report(
166166) {
167167 let ( primary, secondary) = comparison. clone ( ) . summarize_by_category ( & benchmark_map) ;
168168 // Get the combined direction of the primary and secondary summaries
169- let direction = match ( primary. direction ( ) , secondary. direction ( ) ) {
170- ( Some ( d1) , Some ( d2) ) if d1 != d2 => Direction :: Mixed ,
171- ( Some ( d) , Some ( _) | None ) => d,
172- ( None , Some ( d) ) => d,
173- ( None , None ) => return ,
174- } ;
169+ let direction = Direction :: join ( primary. direction ( ) , secondary. direction ( ) ) ;
170+ if direction == Direction :: None {
171+ return ;
172+ }
175173
176174 let include_in_triage = deserves_attention_icount ( & primary, & secondary) ;
177175
@@ -338,9 +336,9 @@ impl ArtifactComparisonSummary {
338336 }
339337
340338 /// The direction of the changes
341- pub fn direction ( & self ) -> Option < Direction > {
339+ pub fn direction ( & self ) -> Direction {
342340 if self . relevant_comparisons . len ( ) == 0 {
343- return None ;
341+ return Direction :: None ;
344342 }
345343
346344 let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) = self
@@ -349,11 +347,11 @@ impl ArtifactComparisonSummary {
349347 . partition ( |c| c. is_regression ( ) ) ;
350348
351349 if regressions. len ( ) == 0 {
352- return Some ( Direction :: Improvement ) ;
350+ return Direction :: Improvement ;
353351 }
354352
355353 if improvements. len ( ) == 0 {
356- return Some ( Direction :: Regression ) ;
354+ return Direction :: Regression ;
357355 }
358356
359357 let total_num = self . relevant_comparisons . len ( ) ;
@@ -369,28 +367,28 @@ impl ArtifactComparisonSummary {
369367 has_medium_and_above_improvements,
370368 has_medium_and_above_regressions,
371369 ) {
372- ( true , true ) => return Some ( Direction :: Mixed ) ,
370+ ( true , true ) => return Direction :: Mixed ,
373371 ( true , false ) => {
374372 if regressions_ratio >= 0.15 {
375- Some ( Direction :: Mixed )
373+ Direction :: Mixed
376374 } else {
377- Some ( Direction :: Improvement )
375+ Direction :: Improvement
378376 }
379377 }
380378 ( false , true ) => {
381379 if regressions_ratio < 0.85 {
382- Some ( Direction :: Mixed )
380+ Direction :: Mixed
383381 } else {
384- Some ( Direction :: Regression )
382+ Direction :: Regression
385383 }
386384 }
387385 ( false , false ) => {
388386 if regressions_ratio >= 0.1 && regressions_ratio <= 0.9 {
389- Some ( Direction :: Mixed )
387+ Direction :: Mixed
390388 } else if regressions_ratio <= 0.1 {
391- Some ( Direction :: Improvement )
389+ Direction :: Improvement
392390 } else {
393- Some ( Direction :: Regression )
391+ Direction :: Regression
394392 }
395393 }
396394 }
@@ -1222,19 +1220,30 @@ impl std::hash::Hash for TestResultComparison {
12221220// The direction of a performance change
12231221#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
12241222pub enum Direction {
1223+ None ,
12251224 Improvement ,
12261225 Regression ,
12271226 Mixed ,
12281227}
12291228
1230- impl std:: fmt:: Display for Direction {
1231- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
1232- let description = match self {
1233- Direction :: Improvement => "improvement" ,
1234- Direction :: Regression => "regression" ,
1235- Direction :: Mixed => "mixed" ,
1236- } ;
1237- write ! ( f, "{}" , description)
1229+ // The direction of a performance change. Forms a lattice:
1230+ //
1231+ // Mixed
1232+ // / \
1233+ // Improvement Regression
1234+ // \ /
1235+ // None
1236+ //
1237+ impl Direction {
1238+ // Also known as the "least upper bound".
1239+ pub fn join ( a : Self , b : Self ) -> Self {
1240+ match ( a, b) {
1241+ ( Self :: None , b) => b,
1242+ ( a, Self :: None ) => a,
1243+ ( Self :: Improvement , Self :: Improvement ) => Self :: Improvement ,
1244+ ( Self :: Regression , Self :: Regression ) => Self :: Regression ,
1245+ _ => Self :: Mixed ,
1246+ }
12381247 }
12391248}
12401249
0 commit comments