@@ -6,7 +6,7 @@ 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 } ;
9
+ use crate :: selector:: { self , CompileBenchmarkQuery , CompileTestCase , TestCase } ;
10
10
11
11
use collector:: benchmark:: category:: Category ;
12
12
use collector:: Bound ;
@@ -798,27 +798,28 @@ async fn compare_given_commits(
798
798
let aids = Arc :: new ( vec ! [ a. clone( ) , b. clone( ) ] ) ;
799
799
800
800
// get all crates, cache, and profile combinations for the given metric
801
- let query = selector :: CompileBenchmarkQuery :: all_for_metric ( metric) ;
801
+ let query = CompileBenchmarkQuery :: all_for_metric ( metric) ;
802
802
803
803
// `responses` contains series iterators. The first element in the iterator is the data
804
804
// for `a` and the second is the data for `b`
805
- let mut responses = ctxt. compile_statistic_series ( query, aids) . await ?;
805
+ let mut responses = ctxt. compile_statistic_series ( query. clone ( ) , aids) . await ?;
806
806
807
807
let conn = ctxt. conn ( ) . await ;
808
808
let statistics_for_a = statistics_from_series ( & mut responses) ;
809
809
let statistics_for_b = statistics_from_series ( & mut responses) ;
810
810
811
811
let mut historical_data =
812
- HistoricalDataMap :: calculate ( ctxt, a. clone ( ) , master_commits, metric) . await ?;
812
+ HistoricalDataMap :: < CompileTestCase > :: calculate ( ctxt, a. clone ( ) , master_commits, query)
813
+ . await ?;
813
814
let comparisons = statistics_for_a
814
815
. into_iter ( )
815
816
. filter_map ( |( test_case, a) | {
816
817
statistics_for_b
817
818
. get ( & test_case)
818
819
. map ( |& b| CompileTestResultComparison {
819
- benchmark : test_case. 0 ,
820
- profile : test_case. 1 ,
821
- scenario : test_case. 2 ,
820
+ benchmark : test_case. benchmark ,
821
+ profile : test_case. profile ,
822
+ scenario : test_case. scenario ,
822
823
comparison : TestResultComparison {
823
824
metric,
824
825
historical_data : historical_data. data . remove ( & test_case) ,
@@ -877,8 +878,7 @@ pub struct ArtifactDescription {
877
878
pub bootstrap_total : u64 ,
878
879
}
879
880
880
- type StatisticsMap = HashMap < TestCase , f64 > ;
881
- type TestCase = ( Benchmark , Profile , Scenario ) ;
881
+ type StatisticsMap < TestCase > = HashMap < TestCase , f64 > ;
882
882
883
883
impl ArtifactDescription {
884
884
/// For the given `ArtifactId`, consume the first datapoint in each of the given `SeriesResponse`
@@ -939,11 +939,13 @@ impl ArtifactDescription {
939
939
}
940
940
}
941
941
942
- fn statistics_from_series < T > ( series : & mut [ selector:: SeriesResponse < T > ] ) -> StatisticsMap
942
+ fn statistics_from_series < Case : TestCase , T > (
943
+ series : & mut [ selector:: SeriesResponse < Case , T > ] ,
944
+ ) -> StatisticsMap < Case >
943
945
where
944
946
T : Iterator < Item = ( ArtifactId , Option < f64 > ) > ,
945
947
{
946
- let mut stats: StatisticsMap = HashMap :: new ( ) ;
948
+ let mut stats: StatisticsMap < Case > = HashMap :: new ( ) ;
947
949
for response in series {
948
950
let ( _, point) = response. series . next ( ) . expect ( "must have element" ) ;
949
951
@@ -952,14 +954,7 @@ where
952
954
} else {
953
955
continue ;
954
956
} ;
955
- stats. insert (
956
- (
957
- response. key . benchmark ,
958
- response. key . profile ,
959
- response. key . scenario ,
960
- ) ,
961
- value,
962
- ) ;
957
+ stats. insert ( response. test_case . clone ( ) , value) ;
963
958
}
964
959
stats
965
960
}
@@ -1053,19 +1048,19 @@ impl ArtifactComparison {
1053
1048
}
1054
1049
1055
1050
/// The historical data for a certain benchmark
1056
- pub struct HistoricalDataMap {
1051
+ pub struct HistoricalDataMap < TestCase > {
1057
1052
/// Historical data on a per test case basis
1058
- pub data : HashMap < ( Benchmark , Profile , Scenario ) , HistoricalData > ,
1053
+ pub data : HashMap < TestCase , HistoricalData > ,
1059
1054
}
1060
1055
1061
- impl HistoricalDataMap {
1056
+ impl HistoricalDataMap < CompileTestCase > {
1062
1057
const NUM_PREVIOUS_COMMITS : usize = 30 ;
1063
1058
1064
1059
async fn calculate (
1065
1060
ctxt : & SiteCtxt ,
1066
1061
from : ArtifactId ,
1067
1062
master_commits : & [ collector:: MasterCommit ] ,
1068
- metric : Metric ,
1063
+ query : CompileBenchmarkQuery ,
1069
1064
) -> Result < Self , BoxedError > {
1070
1065
let mut historical_data = HashMap :: new ( ) ;
1071
1066
@@ -1082,16 +1077,13 @@ impl HistoricalDataMap {
1082
1077
} ) ;
1083
1078
}
1084
1079
1085
- // get all crates, cache, and profile combinations for the given metric
1086
- let query = selector:: CompileBenchmarkQuery :: all_for_metric ( metric) ;
1087
-
1088
1080
let mut previous_commit_series = ctxt
1089
1081
. compile_statistic_series ( query, previous_commits. clone ( ) )
1090
1082
. await ?;
1091
1083
1092
1084
for _ in previous_commits. iter ( ) {
1093
- for ( test_case , stat) in statistics_from_series ( & mut previous_commit_series) {
1094
- historical_data. entry ( test_case ) . or_default ( ) . push ( stat) ;
1085
+ for ( key , stat) in statistics_from_series ( & mut previous_commit_series) {
1086
+ historical_data. entry ( key ) . or_default ( ) . push ( stat) ;
1095
1087
}
1096
1088
}
1097
1089
0 commit comments