@@ -3,12 +3,57 @@ use std::collections::HashMap;
3
3
use std:: sync:: Arc ;
4
4
5
5
use crate :: api:: graphs:: GraphKind ;
6
- use crate :: api:: { graphs, ServerResult } ;
6
+ use crate :: api:: { detail , graphs, ServerResult } ;
7
7
use crate :: db:: { self , ArtifactId , Profile , Scenario } ;
8
8
use crate :: interpolate:: IsInterpolated ;
9
9
use crate :: load:: SiteCtxt ;
10
10
use crate :: selector:: { CompileBenchmarkQuery , CompileTestCase , Selector , SeriesResponse } ;
11
11
12
+ /// Returns data for a detailed information when comparing a single test result comparison
13
+ /// for a compile-time benchmark.
14
+ pub async fn handle_compile_detail (
15
+ request : detail:: Request ,
16
+ ctxt : Arc < SiteCtxt > ,
17
+ ) -> ServerResult < detail:: Response > {
18
+ log:: info!( "handle_compile_detail({:?})" , request) ;
19
+
20
+ let artifact_ids = Arc :: new ( master_artifact_ids_for_range (
21
+ & ctxt,
22
+ request. start ,
23
+ request. end ,
24
+ ) ) ;
25
+
26
+ let interpolated_responses: Vec < _ > = ctxt
27
+ . statistic_series (
28
+ CompileBenchmarkQuery :: default ( )
29
+ . benchmark ( Selector :: One ( request. benchmark ) )
30
+ . profile ( Selector :: One ( request. profile . parse ( ) ?) )
31
+ . scenario ( Selector :: One ( request. scenario . parse ( ) ?) )
32
+ . metric ( Selector :: One ( request. stat . parse ( ) ?) ) ,
33
+ artifact_ids. clone ( ) ,
34
+ )
35
+ . await ?
36
+ . into_iter ( )
37
+ . map ( |sr| sr. interpolate ( ) . map ( |series| series. collect :: < Vec < _ > > ( ) ) )
38
+ . collect ( ) ;
39
+
40
+ let mut graphs = Vec :: new ( ) ;
41
+
42
+ let mut interpolated_responses = interpolated_responses. into_iter ( ) ;
43
+ if let Some ( response) = interpolated_responses. next ( ) {
44
+ let series = response. series . into_iter ( ) . collect :: < Vec < _ > > ( ) ;
45
+ for kind in request. kinds {
46
+ graphs. push ( graph_series ( series. clone ( ) . into_iter ( ) , kind) ) ;
47
+ }
48
+ }
49
+ assert ! ( interpolated_responses. next( ) . is_none( ) ) ;
50
+
51
+ Ok ( detail:: Response {
52
+ commits : artifact_ids_to_commits ( artifact_ids) ,
53
+ graphs,
54
+ } )
55
+ }
56
+
12
57
pub async fn handle_graphs (
13
58
request : graphs:: Request ,
14
59
ctxt : Arc < SiteCtxt > ,
@@ -33,7 +78,7 @@ pub async fn handle_graphs(
33
78
}
34
79
}
35
80
36
- let resp = create_graphs ( request, & ctxt) . await ?;
81
+ let resp = Arc :: new ( create_graphs ( request, & ctxt) . await ?) ;
37
82
38
83
if is_default_query {
39
84
ctxt. landing_page . store ( Arc :: new ( Some ( resp. clone ( ) ) ) ) ;
@@ -45,7 +90,7 @@ pub async fn handle_graphs(
45
90
async fn create_graphs (
46
91
request : graphs:: Request ,
47
92
ctxt : & SiteCtxt ,
48
- ) -> ServerResult < Arc < graphs:: Response > > {
93
+ ) -> ServerResult < graphs:: Response > {
49
94
let artifact_ids = Arc :: new ( master_artifact_ids_for_range (
50
95
ctxt,
51
96
request. start ,
@@ -98,17 +143,21 @@ async fn create_graphs(
98
143
. insert ( scenario, graph_series) ;
99
144
}
100
145
101
- Ok ( Arc :: new ( graphs:: Response {
102
- commits : Arc :: try_unwrap ( artifact_ids)
103
- . unwrap ( )
104
- . into_iter ( )
105
- . map ( |c| match c {
106
- ArtifactId :: Commit ( c) => ( c. date . 0 . timestamp ( ) , c. sha ) ,
107
- ArtifactId :: Tag ( _) => unreachable ! ( ) ,
108
- } )
109
- . collect ( ) ,
146
+ Ok ( graphs:: Response {
147
+ commits : artifact_ids_to_commits ( artifact_ids) ,
110
148
benchmarks,
111
- } ) )
149
+ } )
150
+ }
151
+
152
+ fn artifact_ids_to_commits ( artifact_ids : Arc < Vec < ArtifactId > > ) -> Vec < ( i64 , String ) > {
153
+ Arc :: try_unwrap ( artifact_ids)
154
+ . unwrap ( )
155
+ . into_iter ( )
156
+ . map ( |c| match c {
157
+ ArtifactId :: Commit ( c) => ( c. date . 0 . timestamp ( ) , c. sha ) ,
158
+ ArtifactId :: Tag ( _) => unreachable ! ( ) ,
159
+ } )
160
+ . collect ( )
112
161
}
113
162
114
163
/// Returns master commit artifact IDs for the given range.
0 commit comments