forked from chromedp/cdproto
/
performance.go
74 lines (59 loc) · 1.97 KB
/
performance.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
// Package performance provides the Chrome Debugging Protocol
// commands, types, and events for the Performance domain.
//
// Generated by the chromedp-gen command.
package performance
// Code generated by chromedp-gen. DO NOT EDIT.
import (
"context"
"github.com/jbegley1995/cdproto/cdp"
)
// DisableParams disable collecting and reporting metrics.
type DisableParams struct{}
// Disable disable collecting and reporting metrics.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Performance.disable against the provided context.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Executor) (err error) {
return h.Execute(ctxt, CommandDisable, nil, nil)
}
// EnableParams enable collecting and reporting metrics.
type EnableParams struct{}
// Enable enable collecting and reporting metrics.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Performance.enable against the provided context.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Executor) (err error) {
return h.Execute(ctxt, CommandEnable, nil, nil)
}
// GetMetricsParams retrieve current values of run-time metrics.
type GetMetricsParams struct{}
// GetMetrics retrieve current values of run-time metrics.
func GetMetrics() *GetMetricsParams {
return &GetMetricsParams{}
}
// GetMetricsReturns return values.
type GetMetricsReturns struct {
Metrics []*Metric `json:"metrics,omitempty"` // Current values for run-time metrics.
}
// Do executes Performance.getMetrics against the provided context.
//
// returns:
// metrics - Current values for run-time metrics.
func (p *GetMetricsParams) Do(ctxt context.Context, h cdp.Executor) (metrics []*Metric, err error) {
// execute
var res GetMetricsReturns
err = h.Execute(ctxt, CommandGetMetrics, nil, &res)
if err != nil {
return nil, err
}
return res.Metrics, nil
}
// Command names.
const (
CommandDisable = "Performance.disable"
CommandEnable = "Performance.enable"
CommandGetMetrics = "Performance.getMetrics"
)