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 { croxTraceUrl , processedSelfProfileUrl } from "../self-profile" ;
4
+ import {
5
+ chromeProfileUrl ,
6
+ processedSelfProfileRelativeUrl ,
7
+ } from "../self-profile" ;
5
8
import { openTraceInPerfetto } from "../perfetto" ;
6
9
7
10
function to_seconds ( time ) {
@@ -43,6 +46,106 @@ function fmt_delta(to, delta, is_integral_delta) {
43
46
) } ≈ ${ delta . toFixed ( 3 ) } ">${ text } </span>`;
44
47
}
45
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
+
46
149
function populate_data ( data , state : Selector ) {
47
150
let txt = `${ state . commit . substring ( 0 , 10 ) } : Self profile results for ${
48
151
state . benchmark
@@ -57,79 +160,15 @@ function populate_data(data, state: Selector) {
57
160
txt += `<br><a href="${ self_href } ">query info for just this commit</a>` ;
58
161
}
59
162
document . querySelector ( "#title" ) . innerHTML = txt ;
60
- let dl_link = ( commit , bench , run ) => {
61
- let url = `/perf/download-raw-self-profile?commit=${ commit } &benchmark=${ bench } &scenario=${ run } ` ;
62
- return `<a href="${ url } ">raw</a>` ;
63
- } ;
64
- let processed_link = ( commit , { benchmark, scenario} , ty ) => {
65
- let url = processedSelfProfileUrl ( commit , benchmark , scenario , ty ) ;
66
- return `<a href="${ url } ">${ ty } </a>` ;
67
- } ;
68
- // FIXME: remove this hack and use the PerfettoLink component once this page is
69
- // converted to Vue.
70
- let perfetto_profiler_link = ( id , commit , bench , run ) => {
71
- let link = croxTraceUrl ( commit , bench , run ) ;
72
- let traceTitle = `${ bench } -${ run } (${ commit } )` ;
73
- document . addEventListener ( "click" , ( event ) => {
74
- if ( ( event . target as HTMLElement ) . id === id ) {
75
- openTraceInPerfetto ( link , traceTitle ) ;
76
- }
77
- } ) ;
78
- return `<a href="#" id="${ id } ">Perfetto</a>` ;
79
- } ;
80
- let firefox_profiler_link = ( commit , bench , run ) => {
81
- let crox_url = encodeURIComponent ( croxTraceUrl ( commit , bench , run ) ) ;
82
- let ff_url = `https://profiler.firefox.com/from-url/${ crox_url } /marker-chart/?v=5` ;
83
- return `<a href="${ ff_url } ">Firefox profiler</a>` ;
84
- } ;
163
+
85
164
txt = "" ;
86
165
if ( state . base_commit ) {
87
- txt += `Download/view
88
- ${ dl_link (
89
- state . base_commit ,
90
- state . benchmark ,
91
- state . scenario
92
- ) } ,
93
- ${ processed_link ( state . base_commit , state , "flamegraph" ) } ,
94
- ${ processed_link ( state . base_commit , state , "crox" ) } ,
95
- ${ processed_link (
96
- state . base_commit ,
97
- state ,
98
- "codegen-schedule"
99
- ) }
100
- (${ perfetto_profiler_link (
101
- "perfetto-before" ,
102
- state . base_commit ,
103
- state . benchmark ,
104
- state . scenario
105
- ) } , ${ firefox_profiler_link (
106
- state . base_commit ,
107
- state . benchmark ,
108
- state . scenario
109
- ) } )
110
- results for ${ state . base_commit . substring (
111
- 0 ,
112
- 10
113
- ) } (base commit)`;
166
+ txt += createDownloadLinks ( state , state . base_commit , "base" ) ;
114
167
txt += "<br>" ;
115
168
}
116
- txt += `Download/view
117
- ${ dl_link ( state . commit , state . benchmark , state . scenario ) } ,
118
- ${ processed_link ( state . commit , state , "flamegraph" ) } ,
119
- ${ processed_link ( state . commit , state , "crox" ) } ,
120
- ${ processed_link ( state . commit , state , "codegen-schedule" ) }
121
- (${ perfetto_profiler_link (
122
- "perfetto-after" ,
123
- state . commit ,
124
- state . benchmark ,
125
- state . scenario
126
- ) } , ${ firefox_profiler_link (
127
- state . commit ,
128
- state . benchmark ,
129
- state . scenario
130
- ) } )
131
- results for ${ state . commit . substring ( 0 , 10 ) } (new commit)` ;
132
- // 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
133
172
let profile = ( b ) =>
134
173
b . endsWith ( "-opt" )
135
174
? "Opt"
0 commit comments