2019-11-06 22:36:04 +03:00
|
|
|
// Package profile is for profilers
|
|
|
|
package profile
|
|
|
|
|
|
|
|
type Profile interface {
|
|
|
|
// Start the profiler
|
|
|
|
Start() error
|
|
|
|
// Stop the profiler
|
|
|
|
Stop() error
|
2019-12-08 23:31:16 +03:00
|
|
|
// Name of the profiler
|
|
|
|
String() string
|
2019-11-06 22:36:04 +03:00
|
|
|
}
|
|
|
|
|
2020-02-25 19:42:43 +03:00
|
|
|
var (
|
2020-10-16 09:38:57 +03:00
|
|
|
DefaultProfile Profile = &NoopProfile{}
|
2020-02-25 19:42:43 +03:00
|
|
|
)
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
type NoopProfile struct{}
|
2020-02-25 19:42:43 +03:00
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (p *NoopProfile) Start() error {
|
2020-02-25 19:42:43 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (p *NoopProfile) Stop() error {
|
2020-02-25 19:42:43 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (p *NoopProfile) String() string {
|
2020-02-25 19:42:43 +03:00
|
|
|
return "noop"
|
|
|
|
}
|
|
|
|
|
2019-11-06 22:36:04 +03:00
|
|
|
type Options struct {
|
|
|
|
// Name to use for the profile
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(o *Options)
|
|
|
|
|
|
|
|
// Name of the profile
|
|
|
|
func Name(n string) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Name = n
|
|
|
|
}
|
|
|
|
}
|