@@ -2,12 +2,14 @@ use collector::Bound;
2
2
use std:: collections:: HashMap ;
3
3
use std:: sync:: Arc ;
4
4
5
+ use crate :: api:: detail:: CompilationSections ;
5
6
use crate :: api:: graphs:: GraphKind ;
6
7
use crate :: api:: { detail, graphs, ServerResult } ;
7
8
use crate :: db:: { self , ArtifactId , Profile , Scenario } ;
8
9
use crate :: interpolate:: IsInterpolated ;
9
10
use crate :: load:: SiteCtxt ;
10
11
use crate :: selector:: { CompileBenchmarkQuery , CompileTestCase , Selector , SeriesResponse } ;
12
+ use crate :: self_profile:: { download_and_analyze_self_profile, SelfProfileWithAnalysis } ;
11
13
12
14
/// Returns data for a detailed information when comparing a single test result comparison
13
15
/// for a compile-time benchmark.
@@ -23,12 +25,13 @@ pub async fn handle_compile_detail(
23
25
request. end ,
24
26
) ) ;
25
27
28
+ let scenario = request. scenario . parse ( ) ?;
26
29
let interpolated_responses: Vec < _ > = ctxt
27
30
. statistic_series (
28
31
CompileBenchmarkQuery :: default ( )
29
- . benchmark ( Selector :: One ( request. benchmark ) )
32
+ . benchmark ( Selector :: One ( request. benchmark . clone ( ) ) )
30
33
. profile ( Selector :: One ( request. profile . parse ( ) ?) )
31
- . scenario ( Selector :: One ( request . scenario . parse ( ) ? ) )
34
+ . scenario ( Selector :: One ( scenario) )
32
35
. metric ( Selector :: One ( request. stat . parse ( ) ?) ) ,
33
36
artifact_ids. clone ( ) ,
34
37
)
@@ -37,6 +40,46 @@ pub async fn handle_compile_detail(
37
40
. map ( |sr| sr. interpolate ( ) . map ( |series| series. collect :: < Vec < _ > > ( ) ) )
38
41
. collect ( ) ;
39
42
43
+ async fn calculate_sections (
44
+ ctxt : & SiteCtxt ,
45
+ aid : Option < & ArtifactId > ,
46
+ benchmark : & str ,
47
+ profile : & str ,
48
+ scenario : Scenario ,
49
+ ) -> Option < CompilationSections > {
50
+ match aid {
51
+ Some ( aid) => download_and_analyze_self_profile (
52
+ ctxt,
53
+ aid. clone ( ) ,
54
+ benchmark,
55
+ profile,
56
+ scenario,
57
+ None ,
58
+ )
59
+ . await
60
+ . ok ( )
61
+ . map ( |profile| compute_sections ( & profile) ) ,
62
+ None => None ,
63
+ }
64
+ }
65
+
66
+ let sections_before = calculate_sections (
67
+ & ctxt,
68
+ artifact_ids. get ( 0 ) ,
69
+ & request. benchmark ,
70
+ & request. profile ,
71
+ scenario,
72
+ )
73
+ . await ;
74
+ let sections_after = calculate_sections (
75
+ & ctxt,
76
+ artifact_ids. get ( 1 ) ,
77
+ & request. benchmark ,
78
+ & request. profile ,
79
+ scenario,
80
+ )
81
+ . await ;
82
+
40
83
let mut graphs = Vec :: new ( ) ;
41
84
42
85
let mut interpolated_responses = interpolated_responses. into_iter ( ) ;
@@ -51,9 +94,26 @@ pub async fn handle_compile_detail(
51
94
Ok ( detail:: Response {
52
95
commits : artifact_ids_to_commits ( artifact_ids) ,
53
96
graphs,
97
+ sections_before,
98
+ sections_after,
54
99
} )
55
100
}
56
101
102
+ fn compute_sections ( profile : & SelfProfileWithAnalysis ) -> CompilationSections {
103
+ let mut sections = CompilationSections :: default ( ) ;
104
+ for query in & profile. profile . query_data {
105
+ let query_name = query. label . as_str ( ) . to_lowercase ( ) ;
106
+ if query_name. contains ( "link" ) {
107
+ sections. linker += query. self_time ;
108
+ } else if query_name. contains ( "llvm" ) {
109
+ sections. backend += query. self_time ;
110
+ } else {
111
+ sections. frontend += query. self_time ;
112
+ }
113
+ }
114
+ sections
115
+ }
116
+
57
117
pub async fn handle_graphs (
58
118
request : graphs:: Request ,
59
119
ctxt : Arc < SiteCtxt > ,
0 commit comments