@@ -7,11 +7,12 @@ use crate::db::{ArtifactId, Benchmark, Lookup, Profile, Scenario};
7
7
use crate :: github;
8
8
use crate :: load:: SiteCtxt ;
9
9
use crate :: selector:: { self , Tag } ;
10
- use std:: cmp:: Ordering ;
11
10
11
+ use collector:: category:: Category ;
12
12
use collector:: Bound ;
13
13
use serde:: Serialize ;
14
14
15
+ use std:: cmp:: Ordering ;
15
16
use std:: collections:: { HashMap , HashSet } ;
16
17
use std:: error:: Error ;
17
18
use std:: hash:: Hash ;
@@ -71,7 +72,7 @@ pub async fn handle_triage(
71
72
) ;
72
73
73
74
// handle results of comparison
74
- populate_report ( & comparison, & mut report) . await ;
75
+ populate_report ( ctxt , & comparison, & mut report) . await ;
75
76
76
77
// Check that there is a next commit and that the
77
78
// after commit is not equal to `end`
@@ -142,6 +143,7 @@ pub async fn handle_compare(
142
143
}
143
144
144
145
async fn populate_report (
146
+ ctxt : & SiteCtxt ,
145
147
comparison : & Comparison ,
146
148
report : & mut HashMap < Option < Direction > , Vec < String > > ,
147
149
) {
@@ -153,7 +155,7 @@ async fn populate_report(
153
155
. entry ( confidence. is_definitely_relevant ( ) . then ( || direction) )
154
156
. or_default ( ) ;
155
157
156
- entry. push ( summary . write ( comparison) . await )
158
+ entry. push ( write_summary ( ctxt , comparison) . await )
157
159
}
158
160
}
159
161
}
@@ -206,11 +208,7 @@ impl ComparisonSummary {
206
208
} ;
207
209
comparisons. sort_by ( cmp) ;
208
210
209
- let errors_in = comparison
210
- . new_errors
211
- . keys ( )
212
- . map ( |k| k. as_str ( ) . to_owned ( ) )
213
- . collect :: < Vec < _ > > ( ) ;
211
+ let errors_in = comparison. new_errors . keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
214
212
215
213
Some ( ComparisonSummary {
216
214
comparisons,
@@ -296,16 +294,6 @@ impl ComparisonSummary {
296
294
self . num_regressions
297
295
}
298
296
299
- /// The most relevant changes (based on size)
300
- pub fn most_relevant_changes < ' a > ( & ' a self ) -> [ Option < & TestResultComparison > ; 2 ] {
301
- match self . direction ( ) {
302
- Some ( Direction :: Improvement ) => [ self . largest_improvement ( ) , None ] ,
303
- Some ( Direction :: Regression ) => [ self . largest_regression ( ) , None ] ,
304
- Some ( Direction :: Mixed ) => [ self . largest_improvement ( ) , self . largest_regression ( ) ] ,
305
- None => [ None , None ] ,
306
- }
307
- }
308
-
309
297
/// Arithmetic mean of all improvements as a percent
310
298
pub fn arithmetic_mean_of_improvements ( & self ) -> f64 {
311
299
self . arithmetic_mean ( self . improvements ( ) )
@@ -382,66 +370,32 @@ impl ComparisonSummary {
382
370
_ => ComparisonConfidence :: MaybeRelevant ,
383
371
}
384
372
}
373
+ }
385
374
386
- async fn write ( & self , comparison : & Comparison ) -> String {
387
- let mut result = if let Some ( pr ) = comparison . b . pr {
388
- let title = github :: pr_title ( pr) . await ;
389
- format ! (
390
- "{} [#{}](https://github.com/rust-lang/rust/pull/{}) \n " ,
391
- title , pr , pr
392
- )
393
- } else {
394
- String :: from ( "<Unknown Change> \n " )
395
- } ;
396
- let start = & comparison . a . artifact ;
397
- let end = & comparison. b . artifact ;
398
- let link = & compare_link ( start , end ) ;
399
-
400
- self . write_summary_lines ( & mut result, Some ( link) ) ;
375
+ async fn write_summary ( ctxt : & SiteCtxt , comparison : & Comparison ) -> String {
376
+ use std :: fmt :: Write ;
377
+ let mut result = if let Some ( pr) = comparison . b . pr {
378
+ let title = github :: pr_title ( pr ) . await ;
379
+ format ! (
380
+ "{} [#{}](https://github.com/rust-lang/rust/pull/{})" ,
381
+ title , pr , pr
382
+ )
383
+ } else {
384
+ String :: from ( "<Unknown Change>" )
385
+ } ;
386
+ let start = & comparison. a . artifact ;
387
+ let end = & comparison . b . artifact ;
388
+ let link = & compare_link ( start , end ) ;
389
+ write ! ( & mut result, " [(Comparison Link)]({}) \n " , link) . unwrap ( ) ;
401
390
402
- result
403
- }
391
+ let benchmark_map = ctxt. get_benchmark_category_map ( ) . await ;
392
+ let ( primary, secondary) = comparison. clone ( ) . summarize_by_category ( benchmark_map) ;
393
+ let primary = primary. unwrap_or_else ( ComparisonSummary :: empty) ;
394
+ let secondary = secondary. unwrap_or_else ( ComparisonSummary :: empty) ;
404
395
405
- pub fn write_summary_lines ( & self , result : & mut String , link : Option < & str > ) {
406
- use std:: fmt:: Write ;
407
- if self . num_regressions > 1 {
408
- writeln ! (
409
- result,
410
- "- Arithmetic mean of relevant regressions: {:.1}%" ,
411
- self . arithmetic_mean_of_regressions( )
412
- )
413
- . unwrap ( ) ;
414
- }
415
- if self . num_improvements > 1 {
416
- writeln ! (
417
- result,
418
- "- Arithmetic mean of relevant improvements: {:.1}%" ,
419
- self . arithmetic_mean_of_improvements( )
420
- )
421
- . unwrap ( ) ;
422
- }
423
- if self . num_improvements > 0 && self . num_regressions > 0 {
424
- writeln ! (
425
- result,
426
- "- Arithmetic mean of all relevant changes: {:.1}%" ,
427
- self . arithmetic_mean_of_changes( )
428
- )
429
- . unwrap ( ) ;
430
- }
431
- for change in self . most_relevant_changes ( ) . iter ( ) . filter_map ( |s| * s) {
432
- write ! ( result, "- " ) . unwrap ( ) ;
433
- change. summary_line ( result, link)
434
- }
396
+ write_summary_table ( & primary, & secondary, & mut result) ;
435
397
436
- if !self . errors_in . is_empty ( ) {
437
- write ! (
438
- result,
439
- "- Benchmark(s) {} started failing to build" ,
440
- self . errors_in. join( ", " )
441
- )
442
- . unwrap ( ) ;
443
- }
444
- }
398
+ result
445
399
}
446
400
447
401
/// Writes a Markdown table containing summary of relevant results.
@@ -800,6 +754,7 @@ impl From<ArtifactDescription> for api::comparison::ArtifactDescription {
800
754
}
801
755
802
756
// A comparison of two artifacts
757
+ #[ derive( Clone ) ]
803
758
pub struct Comparison {
804
759
pub a : ArtifactDescription ,
805
760
pub b : ArtifactDescription ,
@@ -836,6 +791,34 @@ impl Comparison {
836
791
pub fn next ( & self , master_commits : & [ collector:: MasterCommit ] ) -> Option < String > {
837
792
next_commit ( & self . b . artifact , master_commits) . map ( |c| c. sha . clone ( ) )
838
793
}
794
+
795
+ /// Splits comparison into primary and secondary summaries based on benchmark category
796
+ pub fn summarize_by_category (
797
+ self ,
798
+ map : HashMap < Benchmark , Category > ,
799
+ ) -> ( Option < ComparisonSummary > , Option < ComparisonSummary > ) {
800
+ let ( primary, secondary) = self
801
+ . statistics
802
+ . into_iter ( )
803
+ . partition ( |s| map. get ( & s. benchmark ( ) ) == Some ( & Category :: Primary ) ) ;
804
+
805
+ let primary = Comparison {
806
+ a : self . a . clone ( ) ,
807
+ b : self . b . clone ( ) ,
808
+ statistics : primary,
809
+ new_errors : self . new_errors . clone ( ) ,
810
+ } ;
811
+ let secondary = Comparison {
812
+ a : self . a ,
813
+ b : self . b ,
814
+ statistics : secondary,
815
+ new_errors : self . new_errors ,
816
+ } ;
817
+ (
818
+ ComparisonSummary :: summarize_comparison ( & primary) ,
819
+ ComparisonSummary :: summarize_comparison ( & secondary) ,
820
+ )
821
+ }
839
822
}
840
823
841
824
/// The historical data for a certain benchmark
@@ -1111,33 +1094,6 @@ impl TestResultComparison {
1111
1094
let ( a, b) = self . results ;
1112
1095
( b - a) / a
1113
1096
}
1114
-
1115
- fn direction ( & self ) -> Direction {
1116
- if self . relative_change ( ) > 0.0 {
1117
- Direction :: Regression
1118
- } else {
1119
- Direction :: Improvement
1120
- }
1121
- }
1122
-
1123
- pub fn summary_line ( & self , summary : & mut String , link : Option < & str > ) {
1124
- use std:: fmt:: Write ;
1125
- let percent = self . relative_change ( ) * 100.0 ;
1126
- writeln ! (
1127
- summary,
1128
- "Largest {} in {}: {:.1}% on `{}` builds of `{} {}`" ,
1129
- self . direction( ) ,
1130
- match link {
1131
- Some ( l) => format!( "[instruction counts]({})" , l) ,
1132
- None => "instruction counts" . into( ) ,
1133
- } ,
1134
- percent,
1135
- self . scenario,
1136
- self . benchmark,
1137
- self . profile
1138
- )
1139
- . unwrap ( ) ;
1140
- }
1141
1097
}
1142
1098
1143
1099
impl std:: cmp:: PartialEq for TestResultComparison {
0 commit comments