@@ -179,13 +179,13 @@ pub struct ArtifactComparisonSummary {
179
179
}
180
180
181
181
impl ArtifactComparisonSummary {
182
- pub fn summarize ( comparison : & ArtifactComparison ) -> Self {
182
+ /// Summarize a collection of `TestResultComparison`
183
+ pub fn summarize ( comparisons : HashSet < TestResultComparison > ) -> Self {
183
184
let mut num_improvements = 0 ;
184
185
let mut num_regressions = 0 ;
185
186
186
- let mut comparisons = comparison
187
- . comparisons
188
- . iter ( )
187
+ let mut relevant_comparisons = comparisons
188
+ . into_iter ( )
189
189
. filter ( |c| c. is_relevant ( ) )
190
190
. inspect ( |c| {
191
191
if c. is_improvement ( ) {
@@ -194,7 +194,6 @@ impl ArtifactComparisonSummary {
194
194
num_regressions += 1
195
195
}
196
196
} )
197
- . cloned ( )
198
197
. collect :: < Vec < _ > > ( ) ;
199
198
200
199
let cmp = |b1 : & TestResultComparison , b2 : & TestResultComparison | {
@@ -203,10 +202,10 @@ impl ArtifactComparisonSummary {
203
202
. partial_cmp ( & b1. relative_change ( ) . abs ( ) )
204
203
. unwrap_or ( std:: cmp:: Ordering :: Equal )
205
204
} ;
206
- comparisons . sort_by ( cmp) ;
205
+ relevant_comparisons . sort_by ( cmp) ;
207
206
208
207
ArtifactComparisonSummary {
209
- relevant_comparisons : comparisons ,
208
+ relevant_comparisons,
210
209
num_improvements,
211
210
num_regressions,
212
211
}
@@ -772,27 +771,9 @@ impl ArtifactComparison {
772
771
. comparisons
773
772
. into_iter ( )
774
773
. partition ( |s| category_map. get ( & s. benchmark ( ) ) == Some ( & Category :: Primary ) ) ;
775
-
776
- let ( primary_errors, secondary_errors) = self
777
- . newly_failed_benchmarks
778
- . into_iter ( )
779
- . partition ( |( b, _) | category_map. get ( & b. as_str ( ) . into ( ) ) == Some ( & Category :: Primary ) ) ;
780
-
781
- let primary = ArtifactComparison {
782
- a : self . a . clone ( ) ,
783
- b : self . b . clone ( ) ,
784
- comparisons : primary,
785
- newly_failed_benchmarks : primary_errors,
786
- } ;
787
- let secondary = ArtifactComparison {
788
- a : self . a ,
789
- b : self . b ,
790
- comparisons : secondary,
791
- newly_failed_benchmarks : secondary_errors,
792
- } ;
793
774
(
794
- ArtifactComparisonSummary :: summarize ( & primary) ,
795
- ArtifactComparisonSummary :: summarize ( & secondary) ,
775
+ ArtifactComparisonSummary :: summarize ( primary) ,
776
+ ArtifactComparisonSummary :: summarize ( secondary) ,
796
777
)
797
778
}
798
779
}
@@ -1230,7 +1211,7 @@ mod tests {
1230
1211
use collector:: category:: Category ;
1231
1212
use std:: collections:: HashSet ;
1232
1213
1233
- use database:: { ArtifactId , Profile , Scenario } ;
1214
+ use database:: { Profile , Scenario } ;
1234
1215
1235
1216
#[ test]
1236
1217
fn summary_table_only_regressions_primary ( ) {
@@ -1430,31 +1411,11 @@ mod tests {
1430
1411
} ) ;
1431
1412
}
1432
1413
1433
- let primary = create_summary ( primary_comparisons) ;
1434
- let secondary = create_summary ( secondary_comparisons) ;
1414
+ let primary = ArtifactComparisonSummary :: summarize ( primary_comparisons) ;
1415
+ let secondary = ArtifactComparisonSummary :: summarize ( secondary_comparisons) ;
1435
1416
1436
1417
let mut result = String :: new ( ) ;
1437
1418
write_summary_table ( & primary, & secondary, true , & mut result) ;
1438
1419
assert_eq ! ( result, expected) ;
1439
1420
}
1440
-
1441
- fn create_summary ( comparisons : HashSet < TestResultComparison > ) -> ArtifactComparisonSummary {
1442
- let comparison = ArtifactComparison {
1443
- a : ArtifactDescription {
1444
- artifact : ArtifactId :: Tag ( "a" . to_string ( ) ) ,
1445
- pr : None ,
1446
- bootstrap : Default :: default ( ) ,
1447
- bootstrap_total : 0 ,
1448
- } ,
1449
- b : ArtifactDescription {
1450
- artifact : ArtifactId :: Tag ( "b" . to_string ( ) ) ,
1451
- pr : None ,
1452
- bootstrap : Default :: default ( ) ,
1453
- bootstrap_total : 0 ,
1454
- } ,
1455
- comparisons,
1456
- newly_failed_benchmarks : Default :: default ( ) ,
1457
- } ;
1458
- ArtifactComparisonSummary :: summarize ( & comparison)
1459
- }
1460
1421
}
0 commit comments