Debian Codegraph @

heapprofiler/heapprofiler.go

raw symbols SCIP
1 // Package heapprofiler provides the Chrome DevTools Protocol
2 // commands, types, and events for the HeapProfiler domain.
3 //
4 // Generated by the cdproto-gen command.
5 package heapprofiler
6
7 // Code generated by cdproto-gen. DO NOT EDIT.
8
9 import (
10 "context"
11
12 "github.com/chromedp/cdproto/cdp"
13 "github.com/chromedp/cdproto/runtime"
14 )
15
16 // AddInspectedHeapObjectParams enables console to refer to the node with
17 // given id via $x (see Command Line API for more details $x functions).
18 type AddInspectedHeapObjectParams struct {
19 HeapObjectID HeapSnapshotObjectID `json:"heapObjectId"` // Heap snapshot object id to be accessible by means of $x command line API.
20 }
21
22 // AddInspectedHeapObject enables console to refer to the node with given id
23 // via $x (see Command Line API for more details $x functions).
24 //
25 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-addInspectedHeapObject
26 //
27 // parameters:
28 //
29 // heapObjectID - Heap snapshot object id to be accessible by means of $x command line API.
30 func AddInspectedHeapObject(heapObjectID HeapSnapshotObjectID) *AddInspectedHeapObjectParams {
31 return &AddInspectedHeapObjectParams{
32 HeapObjectID: heapObjectID,
33 }
34 }
35
36 // Do executes HeapProfiler.addInspectedHeapObject against the provided context.
37 func (p *AddInspectedHeapObjectParams) Do(ctx context.Context) (err error) {
38 return cdp.Execute(ctx, CommandAddInspectedHeapObject, p, nil)
39 }
40
41 // CollectGarbageParams [no description].
42 type CollectGarbageParams struct{}
43
44 // CollectGarbage [no description].
45 //
46 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-collectGarbage
47 func CollectGarbage() *CollectGarbageParams {
48 return &CollectGarbageParams{}
49 }
50
51 // Do executes HeapProfiler.collectGarbage against the provided context.
52 func (p *CollectGarbageParams) Do(ctx context.Context) (err error) {
53 return cdp.Execute(ctx, CommandCollectGarbage, nil, nil)
54 }
55
56 // DisableParams [no description].
57 type DisableParams struct{}
58
59 // Disable [no description].
60 //
61 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-disable
62 func Disable() *DisableParams {
63 return &DisableParams{}
64 }
65
66 // Do executes HeapProfiler.disable against the provided context.
67 func (p *DisableParams) Do(ctx context.Context) (err error) {
68 return cdp.Execute(ctx, CommandDisable, nil, nil)
69 }
70
71 // EnableParams [no description].
72 type EnableParams struct{}
73
74 // Enable [no description].
75 //
76 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-enable
77 func Enable() *EnableParams {
78 return &EnableParams{}
79 }
80
81 // Do executes HeapProfiler.enable against the provided context.
82 func (p *EnableParams) Do(ctx context.Context) (err error) {
83 return cdp.Execute(ctx, CommandEnable, nil, nil)
84 }
85
86 // GetHeapObjectIDParams [no description].
87 type GetHeapObjectIDParams struct {
88 ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to get heap object id for.
89 }
90
91 // GetHeapObjectID [no description].
92 //
93 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-getHeapObjectId
94 //
95 // parameters:
96 //
97 // objectID - Identifier of the object to get heap object id for.
98 func GetHeapObjectID(objectID runtime.RemoteObjectID) *GetHeapObjectIDParams {
99 return &GetHeapObjectIDParams{
100 ObjectID: objectID,
101 }
102 }
103
104 // GetHeapObjectIDReturns return values.
105 type GetHeapObjectIDReturns struct {
106 HeapSnapshotObjectID HeapSnapshotObjectID `json:"heapSnapshotObjectId,omitempty,omitzero"` // Id of the heap snapshot object corresponding to the passed remote object id.
107 }
108
109 // Do executes HeapProfiler.getHeapObjectId against the provided context.
110 //
111 // returns:
112 //
113 // heapSnapshotObjectID - Id of the heap snapshot object corresponding to the passed remote object id.
114 func (p *GetHeapObjectIDParams) Do(ctx context.Context) (heapSnapshotObjectID HeapSnapshotObjectID, err error) {
115 // execute
116 var res GetHeapObjectIDReturns
117 err = cdp.Execute(ctx, CommandGetHeapObjectID, p, &res)
118 if err != nil {
119 return "", err
120 }
121
122 return res.HeapSnapshotObjectID, nil
123 }
124
125 // GetObjectByHeapObjectIDParams [no description].
126 type GetObjectByHeapObjectIDParams struct {
127 ObjectID HeapSnapshotObjectID `json:"objectId"`
128 ObjectGroup string `json:"objectGroup,omitempty,omitzero"` // Symbolic group name that can be used to release multiple objects.
129 }
130
131 // GetObjectByHeapObjectID [no description].
132 //
133 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-getObjectByHeapObjectId
134 //
135 // parameters:
136 //
137 // objectID
138 func GetObjectByHeapObjectID(objectID HeapSnapshotObjectID) *GetObjectByHeapObjectIDParams {
139 return &GetObjectByHeapObjectIDParams{
140 ObjectID: objectID,
141 }
142 }
143
144 // WithObjectGroup symbolic group name that can be used to release multiple
145 // objects.
146 func (p GetObjectByHeapObjectIDParams) WithObjectGroup(objectGroup string) *GetObjectByHeapObjectIDParams {
147 p.ObjectGroup = objectGroup
148 return &p
149 }
150
151 // GetObjectByHeapObjectIDReturns return values.
152 type GetObjectByHeapObjectIDReturns struct {
153 Result *runtime.RemoteObject `json:"result,omitempty,omitzero"` // Evaluation result.
154 }
155
156 // Do executes HeapProfiler.getObjectByHeapObjectId against the provided context.
157 //
158 // returns:
159 //
160 // result - Evaluation result.
161 func (p *GetObjectByHeapObjectIDParams) Do(ctx context.Context) (result *runtime.RemoteObject, err error) {
162 // execute
163 var res GetObjectByHeapObjectIDReturns
164 err = cdp.Execute(ctx, CommandGetObjectByHeapObjectID, p, &res)
165 if err != nil {
166 return nil, err
167 }
168
169 return res.Result, nil
170 }
171
172 // GetSamplingProfileParams [no description].
173 type GetSamplingProfileParams struct{}
174
175 // GetSamplingProfile [no description].
176 //
177 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-getSamplingProfile
178 func GetSamplingProfile() *GetSamplingProfileParams {
179 return &GetSamplingProfileParams{}
180 }
181
182 // GetSamplingProfileReturns return values.
183 type GetSamplingProfileReturns struct {
184 Profile *SamplingHeapProfile `json:"profile,omitempty,omitzero"` // Return the sampling profile being collected.
185 }
186
187 // Do executes HeapProfiler.getSamplingProfile against the provided context.
188 //
189 // returns:
190 //
191 // profile - Return the sampling profile being collected.
192 func (p *GetSamplingProfileParams) Do(ctx context.Context) (profile *SamplingHeapProfile, err error) {
193 // execute
194 var res GetSamplingProfileReturns
195 err = cdp.Execute(ctx, CommandGetSamplingProfile, nil, &res)
196 if err != nil {
197 return nil, err
198 }
199
200 return res.Profile, nil
201 }
202
203 // StartSamplingParams [no description].
204 type StartSamplingParams struct {
205 SamplingInterval float64 `json:"samplingInterval,omitempty,omitzero"` // Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes.
206 IncludeObjectsCollectedByMajorGC bool `json:"includeObjectsCollectedByMajorGC"` // By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by major GC, which will show which functions cause large temporary memory usage or long GC pauses.
207 IncludeObjectsCollectedByMinorGC bool `json:"includeObjectsCollectedByMinorGC"` // By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by minor GC, which is useful when tuning a latency-sensitive application for minimal GC activity.
208 }
209
210 // StartSampling [no description].
211 //
212 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-startSampling
213 //
214 // parameters:
215 func StartSampling() *StartSamplingParams {
216 return &StartSamplingParams{
217 IncludeObjectsCollectedByMajorGC: false,
218 IncludeObjectsCollectedByMinorGC: false,
219 }
220 }
221
222 // WithSamplingInterval average sample interval in bytes. Poisson
223 // distribution is used for the intervals. The default value is 32768 bytes.
224 func (p StartSamplingParams) WithSamplingInterval(samplingInterval float64) *StartSamplingParams {
225 p.SamplingInterval = samplingInterval
226 return &p
227 }
228
229 // WithIncludeObjectsCollectedByMajorGC by default, the sampling heap
230 // profiler reports only objects which are still alive when the profile is
231 // returned via getSamplingProfile or stopSampling, which is useful for
232 // determining what functions contribute the most to steady-state memory usage.
233 // This flag instructs the sampling heap profiler to also include information
234 // about objects discarded by major GC, which will show which functions cause
235 // large temporary memory usage or long GC pauses.
236 func (p StartSamplingParams) WithIncludeObjectsCollectedByMajorGC(includeObjectsCollectedByMajorGC bool) *StartSamplingParams {
237 p.IncludeObjectsCollectedByMajorGC = includeObjectsCollectedByMajorGC
238 return &p
239 }
240
241 // WithIncludeObjectsCollectedByMinorGC by default, the sampling heap
242 // profiler reports only objects which are still alive when the profile is
243 // returned via getSamplingProfile or stopSampling, which is useful for
244 // determining what functions contribute the most to steady-state memory usage.
245 // This flag instructs the sampling heap profiler to also include information
246 // about objects discarded by minor GC, which is useful when tuning a
247 // latency-sensitive application for minimal GC activity.
248 func (p StartSamplingParams) WithIncludeObjectsCollectedByMinorGC(includeObjectsCollectedByMinorGC bool) *StartSamplingParams {
249 p.IncludeObjectsCollectedByMinorGC = includeObjectsCollectedByMinorGC
250 return &p
251 }
252
253 // Do executes HeapProfiler.startSampling against the provided context.
254 func (p *StartSamplingParams) Do(ctx context.Context) (err error) {
255 return cdp.Execute(ctx, CommandStartSampling, p, nil)
256 }
257
258 // StartTrackingHeapObjectsParams [no description].
259 type StartTrackingHeapObjectsParams struct {
260 TrackAllocations bool `json:"trackAllocations"`
261 }
262
263 // StartTrackingHeapObjects [no description].
264 //
265 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-startTrackingHeapObjects
266 //
267 // parameters:
268 func StartTrackingHeapObjects() *StartTrackingHeapObjectsParams {
269 return &StartTrackingHeapObjectsParams{
270 TrackAllocations: false,
271 }
272 }
273
274 // WithTrackAllocations [no description].
275 func (p StartTrackingHeapObjectsParams) WithTrackAllocations(trackAllocations bool) *StartTrackingHeapObjectsParams {
276 p.TrackAllocations = trackAllocations
277 return &p
278 }
279
280 // Do executes HeapProfiler.startTrackingHeapObjects against the provided context.
281 func (p *StartTrackingHeapObjectsParams) Do(ctx context.Context) (err error) {
282 return cdp.Execute(ctx, CommandStartTrackingHeapObjects, p, nil)
283 }
284
285 // StopSamplingParams [no description].
286 type StopSamplingParams struct{}
287
288 // StopSampling [no description].
289 //
290 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-stopSampling
291 func StopSampling() *StopSamplingParams {
292 return &StopSamplingParams{}
293 }
294
295 // StopSamplingReturns return values.
296 type StopSamplingReturns struct {
297 Profile *SamplingHeapProfile `json:"profile,omitempty,omitzero"` // Recorded sampling heap profile.
298 }
299
300 // Do executes HeapProfiler.stopSampling against the provided context.
301 //
302 // returns:
303 //
304 // profile - Recorded sampling heap profile.
305 func (p *StopSamplingParams) Do(ctx context.Context) (profile *SamplingHeapProfile, err error) {
306 // execute
307 var res StopSamplingReturns
308 err = cdp.Execute(ctx, CommandStopSampling, nil, &res)
309 if err != nil {
310 return nil, err
311 }
312
313 return res.Profile, nil
314 }
315
316 // StopTrackingHeapObjectsParams [no description].
317 type StopTrackingHeapObjectsParams struct {
318 ReportProgress bool `json:"reportProgress"` // If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped.
319 CaptureNumericValue bool `json:"captureNumericValue"` // If true, numerical values are included in the snapshot
320 ExposeInternals bool `json:"exposeInternals"` // If true, exposes internals of the snapshot.
321 }
322
323 // StopTrackingHeapObjects [no description].
324 //
325 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-stopTrackingHeapObjects
326 //
327 // parameters:
328 func StopTrackingHeapObjects() *StopTrackingHeapObjectsParams {
329 return &StopTrackingHeapObjectsParams{
330 ReportProgress: false,
331 CaptureNumericValue: false,
332 ExposeInternals: false,
333 }
334 }
335
336 // WithReportProgress if true 'reportHeapSnapshotProgress' events will be
337 // generated while snapshot is being taken when the tracking is stopped.
338 func (p StopTrackingHeapObjectsParams) WithReportProgress(reportProgress bool) *StopTrackingHeapObjectsParams {
339 p.ReportProgress = reportProgress
340 return &p
341 }
342
343 // WithCaptureNumericValue if true, numerical values are included in the
344 // snapshot.
345 func (p StopTrackingHeapObjectsParams) WithCaptureNumericValue(captureNumericValue bool) *StopTrackingHeapObjectsParams {
346 p.CaptureNumericValue = captureNumericValue
347 return &p
348 }
349
350 // WithExposeInternals if true, exposes internals of the snapshot.
351 func (p StopTrackingHeapObjectsParams) WithExposeInternals(exposeInternals bool) *StopTrackingHeapObjectsParams {
352 p.ExposeInternals = exposeInternals
353 return &p
354 }
355
356 // Do executes HeapProfiler.stopTrackingHeapObjects against the provided context.
357 func (p *StopTrackingHeapObjectsParams) Do(ctx context.Context) (err error) {
358 return cdp.Execute(ctx, CommandStopTrackingHeapObjects, p, nil)
359 }
360
361 // TakeHeapSnapshotParams [no description].
362 type TakeHeapSnapshotParams struct {
363 ReportProgress bool `json:"reportProgress"` // If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
364 CaptureNumericValue bool `json:"captureNumericValue"` // If true, numerical values are included in the snapshot
365 ExposeInternals bool `json:"exposeInternals"` // If true, exposes internals of the snapshot.
366 }
367
368 // TakeHeapSnapshot [no description].
369 //
370 // See: https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler#method-takeHeapSnapshot
371 //
372 // parameters:
373 func TakeHeapSnapshot() *TakeHeapSnapshotParams {
374 return &TakeHeapSnapshotParams{
375 ReportProgress: false,
376 CaptureNumericValue: false,
377 ExposeInternals: false,
378 }
379 }
380
381 // WithReportProgress if true 'reportHeapSnapshotProgress' events will be
382 // generated while snapshot is being taken.
383 func (p TakeHeapSnapshotParams) WithReportProgress(reportProgress bool) *TakeHeapSnapshotParams {
384 p.ReportProgress = reportProgress
385 return &p
386 }
387
388 // WithCaptureNumericValue if true, numerical values are included in the
389 // snapshot.
390 func (p TakeHeapSnapshotParams) WithCaptureNumericValue(captureNumericValue bool) *TakeHeapSnapshotParams {
391 p.CaptureNumericValue = captureNumericValue
392 return &p
393 }
394
395 // WithExposeInternals if true, exposes internals of the snapshot.
396 func (p TakeHeapSnapshotParams) WithExposeInternals(exposeInternals bool) *TakeHeapSnapshotParams {
397 p.ExposeInternals = exposeInternals
398 return &p
399 }
400
401 // Do executes HeapProfiler.takeHeapSnapshot against the provided context.
402 func (p *TakeHeapSnapshotParams) Do(ctx context.Context) (err error) {
403 return cdp.Execute(ctx, CommandTakeHeapSnapshot, p, nil)
404 }
405
406 // Command names.
407 const (
408 CommandAddInspectedHeapObject = "HeapProfiler.addInspectedHeapObject"
409 CommandCollectGarbage = "HeapProfiler.collectGarbage"
410 CommandDisable = "HeapProfiler.disable"
411 CommandEnable = "HeapProfiler.enable"
412 CommandGetHeapObjectID = "HeapProfiler.getHeapObjectId"
413 CommandGetObjectByHeapObjectID = "HeapProfiler.getObjectByHeapObjectId"
414 CommandGetSamplingProfile = "HeapProfiler.getSamplingProfile"
415 CommandStartSampling = "HeapProfiler.startSampling"
416 CommandStartTrackingHeapObjects = "HeapProfiler.startTrackingHeapObjects"
417 CommandStopSampling = "HeapProfiler.stopSampling"
418 CommandStopTrackingHeapObjects = "HeapProfiler.stopTrackingHeapObjects"
419 CommandTakeHeapSnapshot = "HeapProfiler.takeHeapSnapshot"
420 )