@@ -6,7 +6,9 @@ use crate::api;
6
6
use crate :: db:: { ArtifactId , Benchmark , Lookup , Profile , Scenario } ;
7
7
use crate :: github;
8
8
use crate :: load:: SiteCtxt ;
9
- use crate :: selector:: { self , BenchmarkQuery , CompileBenchmarkQuery , TestCase } ;
9
+ use crate :: selector:: {
10
+ self , BenchmarkQuery , CompileBenchmarkQuery , RuntimeBenchmarkQuery , TestCase ,
11
+ } ;
10
12
11
13
use collector:: benchmark:: category:: Category ;
12
14
use collector:: Bound ;
@@ -153,6 +155,18 @@ pub async fn handle_compare(
153
155
} )
154
156
. collect ( ) ;
155
157
158
+ let runtime_comparisons = comparison
159
+ . runtime_comparisons
160
+ . into_iter ( )
161
+ . map ( |comparison| api:: comparison:: RuntimeBenchmarkComparison {
162
+ benchmark : comparison. benchmark . to_string ( ) ,
163
+ is_relevant : comparison. is_relevant ( ) ,
164
+ significance_threshold : comparison. significance_threshold ( ) ,
165
+ significance_factor : comparison. significance_factor ( ) ,
166
+ statistics : comparison. results ,
167
+ } )
168
+ . collect ( ) ;
169
+
156
170
let mut new_errors = comparison
157
171
. newly_failed_benchmarks
158
172
. into_iter ( )
@@ -163,6 +177,7 @@ pub async fn handle_compare(
163
177
a : comparison. a . into ( ) ,
164
178
b : comparison. b . into ( ) ,
165
179
compile_comparisons,
180
+ runtime_comparisons,
166
181
new_errors,
167
182
next,
168
183
is_contiguous,
@@ -798,41 +813,38 @@ async fn compare_given_commits(
798
813
let aids = Arc :: new ( vec ! [ a. clone( ) , b. clone( ) ] ) ;
799
814
800
815
// get all crates, cache, and profile combinations for the given metric
801
- let query = CompileBenchmarkQuery :: all_for_metric ( metric) ;
802
-
803
- // `responses` contains series iterators. The first element in the iterator is the data
804
- // for `a` and the second is the data for `b`
805
- let mut responses = ctxt. statistic_series ( query. clone ( ) , aids) . await ?;
806
-
807
- let conn = ctxt. conn ( ) . await ;
808
- let statistics_for_a = statistics_from_series ( & mut responses) ;
809
- let statistics_for_b = statistics_from_series ( & mut responses) ;
816
+ let compile_comparisons = get_comparison :: < CompileTestResultComparison , _ , _ > (
817
+ ctxt,
818
+ CompileBenchmarkQuery :: all_for_metric ( metric) ,
819
+ a. clone ( ) ,
820
+ aids. clone ( ) ,
821
+ metric,
822
+ master_commits,
823
+ |test_case, comparison| CompileTestResultComparison {
824
+ profile : test_case. profile ,
825
+ scenario : test_case. scenario ,
826
+ benchmark : test_case. benchmark ,
827
+ comparison,
828
+ } ,
829
+ )
830
+ . await ?;
810
831
811
- let mut historical_data = HistoricalDataMap :: < CompileBenchmarkQuery > :: calculate (
832
+ // get all crates, cache, and profile combinations for the given metric
833
+ let runtime_comparisons = get_comparison :: < RuntimeTestResultComparison , _ , _ > (
812
834
ctxt,
835
+ RuntimeBenchmarkQuery :: all_for_metric ( metric) ,
813
836
a. clone ( ) ,
837
+ aids,
838
+ metric,
814
839
master_commits,
815
- query,
840
+ |test_case, comparison| RuntimeTestResultComparison {
841
+ benchmark : test_case. benchmark ,
842
+ comparison,
843
+ } ,
816
844
)
817
845
. await ?;
818
- let comparisons = statistics_for_a
819
- . into_iter ( )
820
- . filter_map ( |( test_case, a) | {
821
- statistics_for_b
822
- . get ( & test_case)
823
- . map ( |& b| CompileTestResultComparison {
824
- benchmark : test_case. benchmark ,
825
- profile : test_case. profile ,
826
- scenario : test_case. scenario ,
827
- comparison : TestResultComparison {
828
- metric,
829
- historical_data : historical_data. data . remove ( & test_case) ,
830
- results : ( a, b) ,
831
- } ,
832
- } )
833
- } )
834
- . collect ( ) ;
835
846
847
+ let conn = ctxt. conn ( ) . await ;
836
848
let mut errors_in_b = conn. get_error ( b. lookup ( & idx) . unwrap ( ) ) . await ;
837
849
let errors_in_a = conn. get_error ( a. lookup ( & idx) . unwrap ( ) ) . await ;
838
850
for ( name, _) in errors_in_a {
@@ -842,11 +854,49 @@ async fn compare_given_commits(
842
854
Ok ( Some ( ArtifactComparison {
843
855
a : ArtifactDescription :: for_artifact ( & * conn, a. clone ( ) , master_commits) . await ,
844
856
b : ArtifactDescription :: for_artifact ( & * conn, b. clone ( ) , master_commits) . await ,
845
- compile_comparisons : comparisons,
857
+ compile_comparisons,
858
+ runtime_comparisons,
846
859
newly_failed_benchmarks : errors_in_b. into_iter ( ) . collect ( ) ,
847
860
} ) )
848
861
}
849
862
863
+ async fn get_comparison <
864
+ Comparison : Eq + Hash ,
865
+ Query : BenchmarkQuery ,
866
+ F : Fn ( Query :: TestCase , TestResultComparison ) -> Comparison ,
867
+ > (
868
+ ctxt : & SiteCtxt ,
869
+ query : Query ,
870
+ start_artifact : ArtifactId ,
871
+ aids : Arc < Vec < ArtifactId > > ,
872
+ metric : Metric ,
873
+ master_commits : & [ collector:: MasterCommit ] ,
874
+ func : F ,
875
+ ) -> Result < HashSet < Comparison > , BoxedError > {
876
+ // `responses` contains series iterators. The first element in the iterator is the data
877
+ // for `a` and the second is the data for `b`
878
+ let mut responses = ctxt. statistic_series ( query. clone ( ) , aids) . await ?;
879
+
880
+ let statistics_for_a = statistics_from_series ( & mut responses) ;
881
+ let statistics_for_b = statistics_from_series ( & mut responses) ;
882
+
883
+ let mut historical_data =
884
+ HistoricalDataMap :: < Query > :: calculate ( ctxt, start_artifact, master_commits, query) . await ?;
885
+ Ok ( statistics_for_a
886
+ . into_iter ( )
887
+ . filter_map ( |( test_case, a) | {
888
+ statistics_for_b. get ( & test_case) . map ( |& b| {
889
+ let comparison = TestResultComparison {
890
+ metric,
891
+ historical_data : historical_data. data . remove ( & test_case) ,
892
+ results : ( a, b) ,
893
+ } ;
894
+ func ( test_case, comparison)
895
+ } )
896
+ } )
897
+ . collect ( ) )
898
+ }
899
+
850
900
fn previous_commits (
851
901
mut from : ArtifactId ,
852
902
n : usize ,
@@ -989,6 +1039,8 @@ pub struct ArtifactComparison {
989
1039
pub b : ArtifactDescription ,
990
1040
/// Compile test result comparisons between the two artifacts
991
1041
pub compile_comparisons : HashSet < CompileTestResultComparison > ,
1042
+ /// Runtime test result copmarisons between the two artifacts
1043
+ pub runtime_comparisons : HashSet < RuntimeTestResultComparison > ,
992
1044
/// A map from benchmark name to an error which occured when building `b` but not `a`.
993
1045
pub newly_failed_benchmarks : HashMap < String , String > ,
994
1046
}
@@ -1355,6 +1407,34 @@ impl std::hash::Hash for CompileTestResultComparison {
1355
1407
}
1356
1408
}
1357
1409
1410
+ #[ derive( Debug , Clone ) ]
1411
+ pub struct RuntimeTestResultComparison {
1412
+ benchmark : Benchmark ,
1413
+ comparison : TestResultComparison ,
1414
+ }
1415
+
1416
+ impl Deref for RuntimeTestResultComparison {
1417
+ type Target = TestResultComparison ;
1418
+
1419
+ fn deref ( & self ) -> & Self :: Target {
1420
+ & self . comparison
1421
+ }
1422
+ }
1423
+
1424
+ impl cmp:: PartialEq for RuntimeTestResultComparison {
1425
+ fn eq ( & self , other : & Self ) -> bool {
1426
+ self . benchmark == other. benchmark
1427
+ }
1428
+ }
1429
+
1430
+ impl cmp:: Eq for RuntimeTestResultComparison { }
1431
+
1432
+ impl std:: hash:: Hash for RuntimeTestResultComparison {
1433
+ fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
1434
+ self . benchmark . hash ( state) ;
1435
+ }
1436
+ }
1437
+
1358
1438
// The direction of a performance change
1359
1439
#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
1360
1440
pub enum Direction {
0 commit comments