@@ -166,12 +166,10 @@ async fn populate_report(
166
166
) {
167
167
let ( primary, secondary) = comparison. clone ( ) . summarize_by_category ( & benchmark_map) ;
168
168
// 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
+ }
175
173
176
174
let include_in_triage = deserves_attention_icount ( & primary, & secondary) ;
177
175
@@ -338,9 +336,9 @@ impl ArtifactComparisonSummary {
338
336
}
339
337
340
338
/// The direction of the changes
341
- pub fn direction ( & self ) -> Option < Direction > {
339
+ pub fn direction ( & self ) -> Direction {
342
340
if self . relevant_comparisons . len ( ) == 0 {
343
- return None ;
341
+ return Direction :: None ;
344
342
}
345
343
346
344
let ( regressions, improvements) : ( Vec < & TestResultComparison > , _ ) = self
@@ -349,11 +347,11 @@ impl ArtifactComparisonSummary {
349
347
. partition ( |c| c. is_regression ( ) ) ;
350
348
351
349
if regressions. len ( ) == 0 {
352
- return Some ( Direction :: Improvement ) ;
350
+ return Direction :: Improvement ;
353
351
}
354
352
355
353
if improvements. len ( ) == 0 {
356
- return Some ( Direction :: Regression ) ;
354
+ return Direction :: Regression ;
357
355
}
358
356
359
357
let total_num = self . relevant_comparisons . len ( ) ;
@@ -369,28 +367,28 @@ impl ArtifactComparisonSummary {
369
367
has_medium_and_above_improvements,
370
368
has_medium_and_above_regressions,
371
369
) {
372
- ( true , true ) => return Some ( Direction :: Mixed ) ,
370
+ ( true , true ) => return Direction :: Mixed ,
373
371
( true , false ) => {
374
372
if regressions_ratio >= 0.15 {
375
- Some ( Direction :: Mixed )
373
+ Direction :: Mixed
376
374
} else {
377
- Some ( Direction :: Improvement )
375
+ Direction :: Improvement
378
376
}
379
377
}
380
378
( false , true ) => {
381
379
if regressions_ratio < 0.85 {
382
- Some ( Direction :: Mixed )
380
+ Direction :: Mixed
383
381
} else {
384
- Some ( Direction :: Regression )
382
+ Direction :: Regression
385
383
}
386
384
}
387
385
( false , false ) => {
388
386
if regressions_ratio >= 0.1 && regressions_ratio <= 0.9 {
389
- Some ( Direction :: Mixed )
387
+ Direction :: Mixed
390
388
} else if regressions_ratio <= 0.1 {
391
- Some ( Direction :: Improvement )
389
+ Direction :: Improvement
392
390
} else {
393
- Some ( Direction :: Regression )
391
+ Direction :: Regression
394
392
}
395
393
}
396
394
}
@@ -1222,19 +1220,30 @@ impl std::hash::Hash for TestResultComparison {
1222
1220
// The direction of a performance change
1223
1221
#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
1224
1222
pub enum Direction {
1223
+ None ,
1225
1224
Improvement ,
1226
1225
Regression ,
1227
1226
Mixed ,
1228
1227
}
1229
1228
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
+ }
1238
1247
}
1239
1248
}
1240
1249
0 commit comments