github.com/annwntech/go-micro/v2@v2.9.5/debug/profile/profile.go (about)

     1  // Package profile is for profilers
     2  package profile
     3  
     4  type Profile interface {
     5  	// Start the profiler
     6  	Start() error
     7  	// Stop the profiler
     8  	Stop() error
     9  	// Name of the profiler
    10  	String() string
    11  }
    12  
    13  var (
    14  	DefaultProfile Profile = new(noop)
    15  )
    16  
    17  type noop struct{}
    18  
    19  func (p *noop) Start() error {
    20  	return nil
    21  }
    22  
    23  func (p *noop) Stop() error {
    24  	return nil
    25  }
    26  
    27  func (p *noop) String() string {
    28  	return "noop"
    29  }
    30  
    31  type Options struct {
    32  	// Name to use for the profile
    33  	Name string
    34  }
    35  
    36  type Option func(o *Options)
    37  
    38  // Name of the profile
    39  func Name(n string) Option {
    40  	return func(o *Options) {
    41  		o.Name = n
    42  	}
    43  }