forked from go-rod/rod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiler.go
321 lines (233 loc) · 9.76 KB
/
profiler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// This file is generated by "./lib/proto/generate"
package proto
/*
Profiler
*/
// ProfilerProfileNode Profile node. Holds callsite information, execution statistics and child nodes.
type ProfilerProfileNode struct {
// ID Unique id of the node.
ID int `json:"id"`
// CallFrame Function location.
CallFrame *RuntimeCallFrame `json:"callFrame"`
// HitCount (optional) Number of samples where this node was on top of the call stack.
HitCount *int `json:"hitCount,omitempty"`
// Children (optional) Child node ids.
Children []int `json:"children,omitempty"`
// DeoptReason (optional) The reason of being not optimized. The function may be deoptimized or marked as don't
// optimize.
DeoptReason string `json:"deoptReason,omitempty"`
// PositionTicks (optional) An array of source position ticks.
PositionTicks []*ProfilerPositionTickInfo `json:"positionTicks,omitempty"`
}
// ProfilerProfile Profile.
type ProfilerProfile struct {
// Nodes The list of profile nodes. First item is the root node.
Nodes []*ProfilerProfileNode `json:"nodes"`
// StartTime Profiling start timestamp in microseconds.
StartTime float64 `json:"startTime"`
// EndTime Profiling end timestamp in microseconds.
EndTime float64 `json:"endTime"`
// Samples (optional) Ids of samples top nodes.
Samples []int `json:"samples,omitempty"`
// TimeDeltas (optional) Time intervals between adjacent samples in microseconds. The first delta is relative to the
// profile startTime.
TimeDeltas []int `json:"timeDeltas,omitempty"`
}
// ProfilerPositionTickInfo Specifies a number of samples attributed to a certain source position.
type ProfilerPositionTickInfo struct {
// Line Source line number (1-based).
Line int `json:"line"`
// Ticks Number of samples attributed to the source line.
Ticks int `json:"ticks"`
}
// ProfilerCoverageRange Coverage data for a source range.
type ProfilerCoverageRange struct {
// StartOffset JavaScript script source offset for the range start.
StartOffset int `json:"startOffset"`
// EndOffset JavaScript script source offset for the range end.
EndOffset int `json:"endOffset"`
// Count Collected execution count of the source range.
Count int `json:"count"`
}
// ProfilerFunctionCoverage Coverage data for a JavaScript function.
type ProfilerFunctionCoverage struct {
// FunctionName JavaScript function name.
FunctionName string `json:"functionName"`
// Ranges Source ranges inside the function with coverage data.
Ranges []*ProfilerCoverageRange `json:"ranges"`
// IsBlockCoverage Whether coverage data for this function has block granularity.
IsBlockCoverage bool `json:"isBlockCoverage"`
}
// ProfilerScriptCoverage Coverage data for a JavaScript script.
type ProfilerScriptCoverage struct {
// ScriptID JavaScript script id.
ScriptID RuntimeScriptID `json:"scriptId"`
// URL JavaScript script name or url.
URL string `json:"url"`
// Functions Functions contained in the script that has coverage data.
Functions []*ProfilerFunctionCoverage `json:"functions"`
}
// ProfilerDisable ...
type ProfilerDisable struct {
}
// ProtoReq name
func (m ProfilerDisable) ProtoReq() string { return "Profiler.disable" }
// Call sends the request
func (m ProfilerDisable) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// ProfilerEnable ...
type ProfilerEnable struct {
}
// ProtoReq name
func (m ProfilerEnable) ProtoReq() string { return "Profiler.enable" }
// Call sends the request
func (m ProfilerEnable) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// ProfilerGetBestEffortCoverage Collect coverage data for the current isolate. The coverage data may be incomplete due to
// garbage collection.
type ProfilerGetBestEffortCoverage struct {
}
// ProtoReq name
func (m ProfilerGetBestEffortCoverage) ProtoReq() string { return "Profiler.getBestEffortCoverage" }
// Call the request
func (m ProfilerGetBestEffortCoverage) Call(c Client) (*ProfilerGetBestEffortCoverageResult, error) {
var res ProfilerGetBestEffortCoverageResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// ProfilerGetBestEffortCoverageResult ...
type ProfilerGetBestEffortCoverageResult struct {
// Result Coverage data for the current isolate.
Result []*ProfilerScriptCoverage `json:"result"`
}
// ProfilerSetSamplingInterval Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
type ProfilerSetSamplingInterval struct {
// Interval New sampling interval in microseconds.
Interval int `json:"interval"`
}
// ProtoReq name
func (m ProfilerSetSamplingInterval) ProtoReq() string { return "Profiler.setSamplingInterval" }
// Call sends the request
func (m ProfilerSetSamplingInterval) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// ProfilerStart ...
type ProfilerStart struct {
}
// ProtoReq name
func (m ProfilerStart) ProtoReq() string { return "Profiler.start" }
// Call sends the request
func (m ProfilerStart) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// ProfilerStartPreciseCoverage Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code
// coverage may be incomplete. Enabling prevents running optimized code and resets execution
// counters.
type ProfilerStartPreciseCoverage struct {
// CallCount (optional) Collect accurate call counts beyond simple 'covered' or 'not covered'.
CallCount bool `json:"callCount,omitempty"`
// Detailed (optional) Collect block-based coverage.
Detailed bool `json:"detailed,omitempty"`
// AllowTriggeredUpdates (optional) Allow the backend to send updates on its own initiative
AllowTriggeredUpdates bool `json:"allowTriggeredUpdates,omitempty"`
}
// ProtoReq name
func (m ProfilerStartPreciseCoverage) ProtoReq() string { return "Profiler.startPreciseCoverage" }
// Call the request
func (m ProfilerStartPreciseCoverage) Call(c Client) (*ProfilerStartPreciseCoverageResult, error) {
var res ProfilerStartPreciseCoverageResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// ProfilerStartPreciseCoverageResult ...
type ProfilerStartPreciseCoverageResult struct {
// Timestamp Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
Timestamp float64 `json:"timestamp"`
}
// ProfilerStop ...
type ProfilerStop struct {
}
// ProtoReq name
func (m ProfilerStop) ProtoReq() string { return "Profiler.stop" }
// Call the request
func (m ProfilerStop) Call(c Client) (*ProfilerStopResult, error) {
var res ProfilerStopResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// ProfilerStopResult ...
type ProfilerStopResult struct {
// Profile Recorded profile.
Profile *ProfilerProfile `json:"profile"`
}
// ProfilerStopPreciseCoverage Disable precise code coverage. Disabling releases unnecessary execution count records and allows
// executing optimized code.
type ProfilerStopPreciseCoverage struct {
}
// ProtoReq name
func (m ProfilerStopPreciseCoverage) ProtoReq() string { return "Profiler.stopPreciseCoverage" }
// Call sends the request
func (m ProfilerStopPreciseCoverage) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// ProfilerTakePreciseCoverage Collect coverage data for the current isolate, and resets execution counters. Precise code
// coverage needs to have started.
type ProfilerTakePreciseCoverage struct {
}
// ProtoReq name
func (m ProfilerTakePreciseCoverage) ProtoReq() string { return "Profiler.takePreciseCoverage" }
// Call the request
func (m ProfilerTakePreciseCoverage) Call(c Client) (*ProfilerTakePreciseCoverageResult, error) {
var res ProfilerTakePreciseCoverageResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// ProfilerTakePreciseCoverageResult ...
type ProfilerTakePreciseCoverageResult struct {
// Result Coverage data for the current isolate.
Result []*ProfilerScriptCoverage `json:"result"`
// Timestamp Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
Timestamp float64 `json:"timestamp"`
}
// ProfilerConsoleProfileFinished ...
type ProfilerConsoleProfileFinished struct {
// ID ...
ID string `json:"id"`
// Location Location of console.profileEnd().
Location *DebuggerLocation `json:"location"`
// Profile ...
Profile *ProfilerProfile `json:"profile"`
// Title (optional) Profile title passed as an argument to console.profile().
Title string `json:"title,omitempty"`
}
// ProtoEvent name
func (evt ProfilerConsoleProfileFinished) ProtoEvent() string {
return "Profiler.consoleProfileFinished"
}
// ProfilerConsoleProfileStarted Sent when new profile recording is started using console.profile() call.
type ProfilerConsoleProfileStarted struct {
// ID ...
ID string `json:"id"`
// Location Location of console.profile().
Location *DebuggerLocation `json:"location"`
// Title (optional) Profile title passed as an argument to console.profile().
Title string `json:"title,omitempty"`
}
// ProtoEvent name
func (evt ProfilerConsoleProfileStarted) ProtoEvent() string {
return "Profiler.consoleProfileStarted"
}
// ProfilerPreciseCoverageDeltaUpdate (experimental) Reports coverage delta since the last poll (either from an event like this, or from
// `takePreciseCoverage` for the current isolate. May only be sent if precise code
// coverage has been started. This event can be trigged by the embedder to, for example,
// trigger collection of coverage data immediately at a certain point in time.
type ProfilerPreciseCoverageDeltaUpdate struct {
// Timestamp Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
Timestamp float64 `json:"timestamp"`
// Occasion Identifier for distinguishing coverage events.
Occasion string `json:"occasion"`
// Result Coverage data for the current isolate.
Result []*ProfilerScriptCoverage `json:"result"`
}
// ProtoEvent name
func (evt ProfilerPreciseCoverageDeltaUpdate) ProtoEvent() string {
return "Profiler.preciseCoverageDeltaUpdate"
}