2019-11-06 19:36:04 +00:00
|
|
|
// Package profile is for profilers
|
|
|
|
package profile
|
|
|
|
|
|
|
|
type Profile interface {
|
|
|
|
// Start the profiler
|
|
|
|
Start() error
|
|
|
|
// Stop the profiler
|
|
|
|
Stop() error
|
2019-12-08 20:31:16 +00:00
|
|
|
// Name of the profiler
|
|
|
|
String() string
|
2019-11-06 19:36:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-26 00:42:43 +08:00
|
|
|
var (
|
|
|
|
DefaultProfile Profile = new(noop)
|
|
|
|
)
|
|
|
|
|
|
|
|
type noop struct{}
|
|
|
|
|
|
|
|
func (p *noop) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *noop) Stop() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *noop) String() string {
|
|
|
|
return "noop"
|
|
|
|
}
|
|
|
|
|
2019-11-06 19:36:04 +00: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
|
|
|
|
}
|
|
|
|
}
|