1
1
import { createUrlWithAppendedParams , getUrlParams } from "../utils/navigation" ;
2
2
import { postMsgpack } from "../utils/requests" ;
3
3
import { SELF_PROFILE_DATA_URL } from "../urls" ;
4
+ import {
5
+ chromeProfileUrl ,
6
+ processedSelfProfileRelativeUrl ,
7
+ } from "../self-profile" ;
8
+ import { openTraceInPerfetto } from "../perfetto" ;
4
9
5
10
function to_seconds ( time ) {
6
11
return time / 1000000000 ;
@@ -41,6 +46,106 @@ function fmt_delta(to, delta, is_integral_delta) {
41
46
) } ≈ ${ delta . toFixed ( 3 ) } ">${ text } </span>`;
42
47
}
43
48
49
+ function raw_self_profile_link (
50
+ commit : string ,
51
+ benchmark : string ,
52
+ scenario : string
53
+ ) : string {
54
+ const url = `/perf/download-raw-self-profile?commit=${ commit } &benchmark=${ benchmark } &scenario=${ scenario } ` ;
55
+ return `<a href="${ url } ">raw</a>` ;
56
+ }
57
+
58
+ function processed_link (
59
+ commit : string ,
60
+ benchmark : string ,
61
+ scenario : string ,
62
+ type : string
63
+ ) : string {
64
+ const url = processedSelfProfileRelativeUrl (
65
+ commit ,
66
+ benchmark ,
67
+ scenario ,
68
+ type
69
+ ) ;
70
+ return `<a href="${ url } ">${ type } </a>` ;
71
+ }
72
+
73
+ // FIXME: remove this hack and use the PerfettoLink component once this page is
74
+ // converted to Vue.
75
+ function perfetto_profiler_link (
76
+ id : string ,
77
+ commit : string ,
78
+ benchmark : string ,
79
+ scenario : string
80
+ ) : string {
81
+ let link = chromeProfileUrl ( commit , benchmark , scenario ) ;
82
+ let traceTitle = `${ benchmark } -${ scenario } (${ commit } )` ;
83
+ document . addEventListener ( "click" , ( event ) => {
84
+ if ( ( event . target as HTMLElement ) . id === id ) {
85
+ openTraceInPerfetto ( link , traceTitle ) ;
86
+ }
87
+ } ) ;
88
+ return `<a href="#" id="${ id } ">Perfetto</a>` ;
89
+ }
90
+
91
+ function firefox_profiler_link (
92
+ commit : string ,
93
+ benchmark : string ,
94
+ scenario : string
95
+ ) : string {
96
+ let crox_url = encodeURIComponent (
97
+ chromeProfileUrl ( commit , benchmark , scenario )
98
+ ) ;
99
+ let ff_url = `https://profiler.firefox.com/from-url/${ crox_url } /marker-chart/?v=5` ;
100
+ return `<a href="${ ff_url } ">Firefox profiler</a>` ;
101
+ }
102
+
103
+ function createDownloadLinks (
104
+ state : Selector ,
105
+ commit : string ,
106
+ label : string
107
+ ) : string {
108
+ const raw = raw_self_profile_link (
109
+ state . commit ,
110
+ state . benchmark ,
111
+ state . scenario
112
+ ) ;
113
+ const flamegraph_link = processed_link (
114
+ commit ,
115
+ state . benchmark ,
116
+ state . scenario ,
117
+ "flamegraph"
118
+ ) ;
119
+ const crox_link = processed_link (
120
+ commit ,
121
+ state . benchmark ,
122
+ state . scenario ,
123
+ "crox"
124
+ ) ;
125
+ const codegen = processed_link (
126
+ commit ,
127
+ state . benchmark ,
128
+ state . scenario ,
129
+ "codegen-schedule"
130
+ ) ;
131
+ const perfetto = perfetto_profiler_link (
132
+ `perfetto-${ label } ` ,
133
+ commit ,
134
+ state . benchmark ,
135
+ state . scenario
136
+ ) ;
137
+ const firefox = firefox_profiler_link (
138
+ state . base_commit ,
139
+ state . benchmark ,
140
+ state . scenario
141
+ ) ;
142
+
143
+ return `Download/view ${ raw } , ${ flamegraph_link } , ${ crox_link } , ${ codegen } (${ perfetto } , ${ firefox } ) results for ${ commit . substring (
144
+ 0 ,
145
+ 10
146
+ ) } (${ label } commit)`;
147
+ }
148
+
44
149
function populate_data ( data , state : Selector ) {
45
150
let txt = `${ state . commit . substring ( 0 , 10 ) } : Self profile results for ${
46
151
state . benchmark
@@ -55,65 +160,15 @@ function populate_data(data, state: Selector) {
55
160
txt += `<br><a href="${ self_href } ">query info for just this commit</a>` ;
56
161
}
57
162
document . querySelector ( "#title" ) . innerHTML = txt ;
58
- let dl_link = ( commit , bench , run ) => {
59
- let url = `/perf/download-raw-self-profile?commit=${ commit } &benchmark=${ bench } &scenario=${ run } ` ;
60
- return `<a href="${ url } ">raw</a>` ;
61
- } ;
62
- let processed_url = ( commit , bench , run , ty ) => {
63
- return `/perf/processed-self-profile?commit=${ commit } &benchmark=${ bench } &scenario=${ run } &type=${ ty } ` ;
64
- } ;
65
- let processed_link = ( commit , { benchmark, scenario} , ty ) => {
66
- let url = processed_url ( commit , benchmark , scenario , ty ) ;
67
- return `<a href="${ url } ">${ ty } </a>` ;
68
- } ;
69
- let processed_crox_url = ( commit , bench , run ) => {
70
- let crox_url =
71
- window . location . origin + processed_url ( commit , bench , run , "crox" ) ;
72
- return encodeURIComponent ( crox_url ) ;
73
- } ;
74
- let firefox_profiler_link = ( commit , bench , run ) => {
75
- let crox_url = processed_crox_url ( commit , bench , run ) ;
76
- let ff_url = `https://profiler.firefox.com/from-url/${ crox_url } /marker-chart/?v=5` ;
77
- return `<a href="${ ff_url } ">Firefox profiler</a>` ;
78
- } ;
163
+
79
164
txt = "" ;
80
165
if ( state . base_commit ) {
81
- txt += `Download/view
82
- ${ dl_link (
83
- state . base_commit ,
84
- state . benchmark ,
85
- state . scenario
86
- ) } ,
87
- ${ processed_link ( state . base_commit , state , "flamegraph" ) } ,
88
- ${ processed_link ( state . base_commit , state , "crox" ) } ,
89
- ${ processed_link (
90
- state . base_commit ,
91
- state ,
92
- "codegen-schedule"
93
- ) }
94
- (${ firefox_profiler_link (
95
- state . base_commit ,
96
- state . benchmark ,
97
- state . scenario
98
- ) } )
99
- results for ${ state . base_commit . substring (
100
- 0 ,
101
- 10
102
- ) } (base commit)`;
166
+ txt += createDownloadLinks ( state , state . base_commit , "base" ) ;
103
167
txt += "<br>" ;
104
168
}
105
- txt += `Download/view
106
- ${ dl_link ( state . commit , state . benchmark , state . scenario ) } ,
107
- ${ processed_link ( state . commit , state , "flamegraph" ) } ,
108
- ${ processed_link ( state . commit , state , "crox" ) } ,
109
- ${ processed_link ( state . commit , state , "codegen-schedule" ) }
110
- (${ firefox_profiler_link (
111
- state . commit ,
112
- state . benchmark ,
113
- state . scenario
114
- ) } )
115
- results for ${ state . commit . substring ( 0 , 10 ) } (new commit)` ;
116
- // TODO: use the Cachegrind Vue components once this page is refactored to Vue
169
+ txt += createDownloadLinks ( state , state . commit , "new" ) ;
170
+
171
+ // FIXME: use the Cachegrind Vue components once this page is refactored to Vue
117
172
let profile = ( b ) =>
118
173
b . endsWith ( "-opt" )
119
174
? "Opt"
0 commit comments