@@ -179,13 +179,13 @@ pub struct ArtifactComparisonSummary {
179179}
180180
181181impl ArtifactComparisonSummary {
182- pub fn summarize ( comparison : & ArtifactComparison ) -> Self {
182+ /// Summarize a collection of `TestResultComparison`
183+ pub fn summarize ( comparisons : HashSet < TestResultComparison > ) -> Self {
183184 let mut num_improvements = 0 ;
184185 let mut num_regressions = 0 ;
185186
186- let mut comparisons = comparison
187- . comparisons
188- . iter ( )
187+ let mut relevant_comparisons = comparisons
188+ . into_iter ( )
189189 . filter ( |c| c. is_relevant ( ) )
190190 . inspect ( |c| {
191191 if c. is_improvement ( ) {
@@ -194,7 +194,6 @@ impl ArtifactComparisonSummary {
194194 num_regressions += 1
195195 }
196196 } )
197- . cloned ( )
198197 . collect :: < Vec < _ > > ( ) ;
199198
200199 let cmp = |b1 : & TestResultComparison , b2 : & TestResultComparison | {
@@ -203,10 +202,10 @@ impl ArtifactComparisonSummary {
203202 . partial_cmp ( & b1. relative_change ( ) . abs ( ) )
204203 . unwrap_or ( std:: cmp:: Ordering :: Equal )
205204 } ;
206- comparisons . sort_by ( cmp) ;
205+ relevant_comparisons . sort_by ( cmp) ;
207206
208207 ArtifactComparisonSummary {
209- relevant_comparisons : comparisons ,
208+ relevant_comparisons,
210209 num_improvements,
211210 num_regressions,
212211 }
@@ -772,27 +771,9 @@ impl ArtifactComparison {
772771 . comparisons
773772 . into_iter ( )
774773 . 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- } ;
793774 (
794- ArtifactComparisonSummary :: summarize ( & primary) ,
795- ArtifactComparisonSummary :: summarize ( & secondary) ,
775+ ArtifactComparisonSummary :: summarize ( primary) ,
776+ ArtifactComparisonSummary :: summarize ( secondary) ,
796777 )
797778 }
798779}
@@ -1230,7 +1211,7 @@ mod tests {
12301211 use collector:: category:: Category ;
12311212 use std:: collections:: HashSet ;
12321213
1233- use database:: { ArtifactId , Profile , Scenario } ;
1214+ use database:: { Profile , Scenario } ;
12341215
12351216 #[ test]
12361217 fn summary_table_only_regressions_primary ( ) {
@@ -1430,31 +1411,11 @@ mod tests {
14301411 } ) ;
14311412 }
14321413
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) ;
14351416
14361417 let mut result = String :: new ( ) ;
14371418 write_summary_table ( & primary, & secondary, true , & mut result) ;
14381419 assert_eq ! ( result, expected) ;
14391420 }
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- }
14601421}
0 commit comments