@@ -103,11 +103,7 @@ pub async fn handle_compare(
103
103
benchmark : comparison. benchmark . to_string ( ) ,
104
104
profile : comparison. profile . to_string ( ) ,
105
105
scenario : comparison. scenario . to_string ( ) ,
106
- is_dodgy : comparison
107
- . variance
108
- . as_ref ( )
109
- . map ( |v| v. is_dodgy ( ) )
110
- . unwrap_or ( false ) ,
106
+ is_dodgy : comparison. is_dodgy ( ) ,
111
107
is_significant : comparison. is_significant ( ) ,
112
108
historical_statistics : comparison. variance . map ( |v| v. data ) ,
113
109
statistics : comparison. results ,
@@ -135,8 +131,8 @@ async fn populate_report(comparison: &Comparison, report: &mut HashMap<Direction
135
131
}
136
132
137
133
pub struct ComparisonSummary {
138
- hi : Option < BenchmarkComparison > ,
139
- lo : Option < BenchmarkComparison > ,
134
+ hi : Option < TestResultComparison > ,
135
+ lo : Option < TestResultComparison > ,
140
136
}
141
137
142
138
impl ComparisonSummary {
@@ -147,7 +143,7 @@ impl ComparisonSummary {
147
143
return None ;
148
144
}
149
145
150
- let cmp = |b1 : & BenchmarkComparison , b2 : & BenchmarkComparison | {
146
+ let cmp = |b1 : & TestResultComparison , b2 : & TestResultComparison | {
151
147
b1. log_change ( )
152
148
. partial_cmp ( & b2. log_change ( ) )
153
149
. unwrap_or ( std:: cmp:: Ordering :: Equal )
@@ -183,7 +179,7 @@ impl ComparisonSummary {
183
179
}
184
180
185
181
/// The changes ordered by their signficance (most significant first)
186
- pub fn ordered_changes ( & self ) -> Vec < & BenchmarkComparison > {
182
+ pub fn ordered_changes ( & self ) -> Vec < & TestResultComparison > {
187
183
match ( & self . hi , & self . lo ) {
188
184
( None , None ) => Vec :: new ( ) ,
189
185
( Some ( b) , None ) => vec ! [ b] ,
@@ -276,7 +272,7 @@ async fn compare_given_commits(
276
272
. filter_map ( |( test_case, a) | {
277
273
statistics_for_b
278
274
. get ( & test_case)
279
- . map ( |& b| BenchmarkComparison {
275
+ . map ( |& b| TestResultComparison {
280
276
benchmark : test_case. 0 ,
281
277
profile : test_case. 1 ,
282
278
scenario : test_case. 2 ,
@@ -423,7 +419,7 @@ pub struct Comparison {
423
419
pub a : ArtifactDescription ,
424
420
pub b : ArtifactDescription ,
425
421
/// Statistics based on test case
426
- pub statistics : HashSet < BenchmarkComparison > ,
422
+ pub statistics : HashSet < TestResultComparison > ,
427
423
}
428
424
429
425
impl Comparison {
@@ -455,7 +451,7 @@ impl Comparison {
455
451
next_commit ( & self . b . artifact , master_commits) . map ( |c| c. sha . clone ( ) )
456
452
}
457
453
458
- fn get_benchmarks ( & self ) -> impl Iterator < Item = & BenchmarkComparison > {
454
+ fn get_benchmarks ( & self ) -> impl Iterator < Item = & TestResultComparison > {
459
455
self . statistics . iter ( ) . filter ( |b| b. profile != Profile :: Doc )
460
456
}
461
457
}
@@ -631,18 +627,25 @@ pub fn next_commit<'a>(
631
627
}
632
628
}
633
629
634
- // A single comparison based on benchmark and cache state
630
+ // A single comparison between two test results
635
631
#[ derive( Debug , Clone ) ]
636
- pub struct BenchmarkComparison {
632
+ pub struct TestResultComparison {
637
633
benchmark : Benchmark ,
638
634
profile : Profile ,
639
635
scenario : Scenario ,
640
636
variance : Option < BenchmarkVariance > ,
641
637
results : ( f64 , f64 ) ,
642
638
}
643
639
644
- const SIGNIFICANCE_THRESHOLD : f64 = 0.001 ;
645
- impl BenchmarkComparison {
640
+ impl TestResultComparison {
641
+ /// The amount of relative change considered significant when
642
+ /// the test case is not dodgy
643
+ const SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD : f64 = 0.01 ;
644
+
645
+ /// The amount of relative change considered significant when
646
+ /// the test case is dodgy
647
+ const SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD_DODGY : f64 = 1.0 ;
648
+
646
649
fn log_change ( & self ) -> f64 {
647
650
let ( a, b) = self . results ;
648
651
( b / a) . ln ( )
@@ -654,15 +657,20 @@ impl BenchmarkComparison {
654
657
}
655
658
656
659
fn is_significant ( & self ) -> bool {
657
- // This particular test case frequently varies
658
- if & self . benchmark == "coercions"
659
- && self . profile == Profile :: Debug
660
- && matches ! ( self . scenario, Scenario :: IncrementalPatch ( p) if & p == "println" )
661
- {
662
- self . relative_change ( ) . abs ( ) > 2.0
660
+ let threshold = if self . is_dodgy ( ) {
661
+ Self :: SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD_DODGY
663
662
} else {
664
- self . log_change ( ) . abs ( ) > SIGNIFICANCE_THRESHOLD
665
- }
663
+ Self :: SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD
664
+ } ;
665
+
666
+ self . relative_change ( ) . abs ( ) > threshold
667
+ }
668
+
669
+ fn is_dodgy ( & self ) -> bool {
670
+ self . variance
671
+ . as_ref ( )
672
+ . map ( |v| v. is_dodgy ( ) )
673
+ . unwrap_or ( false )
666
674
}
667
675
668
676
fn relative_change ( & self ) -> f64 {
@@ -671,7 +679,7 @@ impl BenchmarkComparison {
671
679
}
672
680
673
681
fn direction ( & self ) -> Direction {
674
- if self . log_change ( ) > 0.0 {
682
+ if self . relative_change ( ) > 0.0 {
675
683
Direction :: Regression
676
684
} else {
677
685
Direction :: Improvement
@@ -680,7 +688,7 @@ impl BenchmarkComparison {
680
688
681
689
pub fn summary_line ( & self , summary : & mut String , link : Option < & str > ) {
682
690
use std:: fmt:: Write ;
683
- let magnitude = self . log_change ( ) . abs ( ) ;
691
+ let magnitude = self . relative_change ( ) . abs ( ) ;
684
692
let size = if magnitude > 0.10 {
685
693
"Very large"
686
694
} else if magnitude > 0.05 {
@@ -713,16 +721,16 @@ impl BenchmarkComparison {
713
721
. unwrap ( ) ;
714
722
}
715
723
}
716
- impl std:: cmp:: PartialEq for BenchmarkComparison {
724
+ impl std:: cmp:: PartialEq for TestResultComparison {
717
725
fn eq ( & self , other : & Self ) -> bool {
718
726
self . benchmark == other. benchmark
719
727
&& self . profile == other. profile
720
728
&& self . scenario == other. scenario
721
729
}
722
730
}
723
- impl std:: cmp:: Eq for BenchmarkComparison { }
731
+ impl std:: cmp:: Eq for TestResultComparison { }
724
732
725
- impl std:: hash:: Hash for BenchmarkComparison {
733
+ impl std:: hash:: Hash for TestResultComparison {
726
734
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
727
735
self . benchmark . hash ( state) ;
728
736
self . profile . hash ( state) ;
0 commit comments