123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- // Package profiler provides the Chrome DevTools Protocol
- // commands, types, and events for the Profiler domain.
- //
- // Generated by the cdproto-gen command.
- package profiler
- // Code generated by cdproto-gen. DO NOT EDIT.
- import (
- "context"
- "github.com/chromedp/cdproto/cdp"
- )
- // DisableParams [no description].
- type DisableParams struct{}
- // Disable [no description].
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-disable
- func Disable() *DisableParams {
- return &DisableParams{}
- }
- // Do executes Profiler.disable against the provided context.
- func (p *DisableParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandDisable, nil, nil)
- }
- // EnableParams [no description].
- type EnableParams struct{}
- // Enable [no description].
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-enable
- func Enable() *EnableParams {
- return &EnableParams{}
- }
- // Do executes Profiler.enable against the provided context.
- func (p *EnableParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandEnable, nil, nil)
- }
- // GetBestEffortCoverageParams collect coverage data for the current isolate.
- // The coverage data may be incomplete due to garbage collection.
- type GetBestEffortCoverageParams struct{}
- // GetBestEffortCoverage collect coverage data for the current isolate. The
- // coverage data may be incomplete due to garbage collection.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-getBestEffortCoverage
- func GetBestEffortCoverage() *GetBestEffortCoverageParams {
- return &GetBestEffortCoverageParams{}
- }
- // GetBestEffortCoverageReturns return values.
- type GetBestEffortCoverageReturns struct {
- Result []*ScriptCoverage `json:"result,omitempty"` // Coverage data for the current isolate.
- }
- // Do executes Profiler.getBestEffortCoverage against the provided context.
- //
- // returns:
- //
- // result - Coverage data for the current isolate.
- func (p *GetBestEffortCoverageParams) Do(ctx context.Context) (result []*ScriptCoverage, err error) {
- // execute
- var res GetBestEffortCoverageReturns
- err = cdp.Execute(ctx, CommandGetBestEffortCoverage, nil, &res)
- if err != nil {
- return nil, err
- }
- return res.Result, nil
- }
- // SetSamplingIntervalParams changes CPU profiler sampling interval. Must be
- // called before CPU profiles recording started.
- type SetSamplingIntervalParams struct {
- Interval int64 `json:"interval"` // New sampling interval in microseconds.
- }
- // SetSamplingInterval changes CPU profiler sampling interval. Must be called
- // before CPU profiles recording started.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-setSamplingInterval
- //
- // parameters:
- //
- // interval - New sampling interval in microseconds.
- func SetSamplingInterval(interval int64) *SetSamplingIntervalParams {
- return &SetSamplingIntervalParams{
- Interval: interval,
- }
- }
- // Do executes Profiler.setSamplingInterval against the provided context.
- func (p *SetSamplingIntervalParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandSetSamplingInterval, p, nil)
- }
- // StartParams [no description].
- type StartParams struct{}
- // Start [no description].
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-start
- func Start() *StartParams {
- return &StartParams{}
- }
- // Do executes Profiler.start against the provided context.
- func (p *StartParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandStart, nil, nil)
- }
- // StartPreciseCoverageParams 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 StartPreciseCoverageParams struct {
- CallCount bool `json:"callCount,omitempty"` // Collect accurate call counts beyond simple 'covered' or 'not covered'.
- Detailed bool `json:"detailed,omitempty"` // Collect block-based coverage.
- AllowTriggeredUpdates bool `json:"allowTriggeredUpdates,omitempty"` // Allow the backend to send updates on its own initiative
- }
- // StartPreciseCoverage 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.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-startPreciseCoverage
- //
- // parameters:
- func StartPreciseCoverage() *StartPreciseCoverageParams {
- return &StartPreciseCoverageParams{}
- }
- // WithCallCount collect accurate call counts beyond simple 'covered' or 'not
- // covered'.
- func (p StartPreciseCoverageParams) WithCallCount(callCount bool) *StartPreciseCoverageParams {
- p.CallCount = callCount
- return &p
- }
- // WithDetailed collect block-based coverage.
- func (p StartPreciseCoverageParams) WithDetailed(detailed bool) *StartPreciseCoverageParams {
- p.Detailed = detailed
- return &p
- }
- // WithAllowTriggeredUpdates allow the backend to send updates on its own
- // initiative.
- func (p StartPreciseCoverageParams) WithAllowTriggeredUpdates(allowTriggeredUpdates bool) *StartPreciseCoverageParams {
- p.AllowTriggeredUpdates = allowTriggeredUpdates
- return &p
- }
- // StartPreciseCoverageReturns return values.
- type StartPreciseCoverageReturns struct {
- Timestamp float64 `json:"timestamp,omitempty"` // Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
- }
- // Do executes Profiler.startPreciseCoverage against the provided context.
- //
- // returns:
- //
- // timestamp - Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
- func (p *StartPreciseCoverageParams) Do(ctx context.Context) (timestamp float64, err error) {
- // execute
- var res StartPreciseCoverageReturns
- err = cdp.Execute(ctx, CommandStartPreciseCoverage, p, &res)
- if err != nil {
- return 0, err
- }
- return res.Timestamp, nil
- }
- // StopParams [no description].
- type StopParams struct{}
- // Stop [no description].
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-stop
- func Stop() *StopParams {
- return &StopParams{}
- }
- // StopReturns return values.
- type StopReturns struct {
- Profile *Profile `json:"profile,omitempty"` // Recorded profile.
- }
- // Do executes Profiler.stop against the provided context.
- //
- // returns:
- //
- // profile - Recorded profile.
- func (p *StopParams) Do(ctx context.Context) (profile *Profile, err error) {
- // execute
- var res StopReturns
- err = cdp.Execute(ctx, CommandStop, nil, &res)
- if err != nil {
- return nil, err
- }
- return res.Profile, nil
- }
- // StopPreciseCoverageParams disable precise code coverage. Disabling
- // releases unnecessary execution count records and allows executing optimized
- // code.
- type StopPreciseCoverageParams struct{}
- // StopPreciseCoverage disable precise code coverage. Disabling releases
- // unnecessary execution count records and allows executing optimized code.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-stopPreciseCoverage
- func StopPreciseCoverage() *StopPreciseCoverageParams {
- return &StopPreciseCoverageParams{}
- }
- // Do executes Profiler.stopPreciseCoverage against the provided context.
- func (p *StopPreciseCoverageParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandStopPreciseCoverage, nil, nil)
- }
- // TakePreciseCoverageParams collect coverage data for the current isolate,
- // and resets execution counters. Precise code coverage needs to have started.
- type TakePreciseCoverageParams struct{}
- // TakePreciseCoverage collect coverage data for the current isolate, and
- // resets execution counters. Precise code coverage needs to have started.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-takePreciseCoverage
- func TakePreciseCoverage() *TakePreciseCoverageParams {
- return &TakePreciseCoverageParams{}
- }
- // TakePreciseCoverageReturns return values.
- type TakePreciseCoverageReturns struct {
- Result []*ScriptCoverage `json:"result,omitempty"` // Coverage data for the current isolate.
- Timestamp float64 `json:"timestamp,omitempty"` // Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
- }
- // Do executes Profiler.takePreciseCoverage against the provided context.
- //
- // returns:
- //
- // result - Coverage data for the current isolate.
- // timestamp - Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
- func (p *TakePreciseCoverageParams) Do(ctx context.Context) (result []*ScriptCoverage, timestamp float64, err error) {
- // execute
- var res TakePreciseCoverageReturns
- err = cdp.Execute(ctx, CommandTakePreciseCoverage, nil, &res)
- if err != nil {
- return nil, 0, err
- }
- return res.Result, res.Timestamp, nil
- }
- // Command names.
- const (
- CommandDisable = "Profiler.disable"
- CommandEnable = "Profiler.enable"
- CommandGetBestEffortCoverage = "Profiler.getBestEffortCoverage"
- CommandSetSamplingInterval = "Profiler.setSamplingInterval"
- CommandStart = "Profiler.start"
- CommandStartPreciseCoverage = "Profiler.startPreciseCoverage"
- CommandStop = "Profiler.stop"
- CommandStopPreciseCoverage = "Profiler.stopPreciseCoverage"
- CommandTakePreciseCoverage = "Profiler.takePreciseCoverage"
- )
|