Documentation ¶
Overview ¶
Package benchmark provides benchmarking facilities to the standard application system.
Index ¶
- Variables
- type Complexity
- type Counters
- type DurationCounter
- func (c *DurationCounter) Add(t time.Duration)
- func (c *DurationCounter) Get() time.Duration
- func (c *DurationCounter) Reset()
- func (c *DurationCounter) Set(t time.Duration)
- func (c *DurationCounter) Start() time.Time
- func (c *DurationCounter) Stop(startTime time.Time)
- func (c *DurationCounter) Time(f func())
- type Fit
- type IntegerCounter
- type LinearFit
- type Sample
- type Samples
Constants ¶
This section is empty.
Variables ¶
var GlobalCounters = NewCounters()
GlobalCounters is a singleton set of performance counters.
var LinearTime linearTime
LinearTime represents an algorithmic complexity of O(n).
Functions ¶
This section is empty.
Types ¶
type Complexity ¶
Complexity represents the complexity of an algorithm.
type Counters ¶
type Counters struct {
// contains filtered or unexported fields
}
Counters represents a collection of named performance counters.
Individual counters are created on retrieve if they do not exist. Counters of different types with the same name are disallowed. Users are encouraged to hang on to retrieved counters rather than calling these methods repeatedly, for performance reasons.
func (*Counters) Duration ¶
func (m *Counters) Duration(name string) *DurationCounter
Duration returns the DurationCounter with the given name, instantiating a new one if necessary.
func (*Counters) Integer ¶
func (m *Counters) Integer(name string) *IntegerCounter
Integer returns the IntegerCounter with the given name, instantiating a new one if necessary.
type DurationCounter ¶
type DurationCounter int64
DurationCounter is a Counter that holds an int64, exposed as a time.Duration.
func Duration ¶ added in v0.9.0
func Duration(name string) *DurationCounter
Duration is a convenience function for calling GlobalCounters.Duration(name).
func (*DurationCounter) Add ¶ added in v0.9.0
func (c *DurationCounter) Add(t time.Duration)
Add adds the given duration to the value of this counter.
func (*DurationCounter) Get ¶
func (c *DurationCounter) Get() time.Duration
Get retrieves the value of this counter as a time.Duration.
func (*DurationCounter) Set ¶ added in v0.9.0
func (c *DurationCounter) Set(t time.Duration)
Set resets the counter to t.
func (*DurationCounter) Start ¶
func (c *DurationCounter) Start() time.Time
Start returns the current time. It's meant to be used with Stop() as a way to time blocks of code and add their durations to the counter.
func (*DurationCounter) Stop ¶
func (c *DurationCounter) Stop(startTime time.Time)
Stop adds to the value of this counter the Duration elapsed since the time.Time received as argument.
func (*DurationCounter) Time ¶ added in v0.9.0
func (c *DurationCounter) Time(f func())
Time times the call to f, adding the timed duration to the counter.
type IntegerCounter ¶
type IntegerCounter int64
IntegerCounter is a Counter that holds an int64 value.
func Integer ¶ added in v0.9.0
func Integer(name string) *IntegerCounter
Integer is a convenience function for calling GlobalCounters.Integer(name).
func (*IntegerCounter) Add ¶ added in v0.9.0
func (c *IntegerCounter) Add(i int64)
Add adds the given value to the value of this counter.
func (*IntegerCounter) Increment ¶
func (c *IntegerCounter) Increment()
Increment adds 1 to the value of this counter.
func (*IntegerCounter) Set ¶ added in v0.9.0
func (c *IntegerCounter) Set(v int64)
Set assigns v to the counter.
type LinearFit ¶
type LinearFit struct {
// contains filtered or unexported fields
}
LinearFit is a linear time fitting (y = α + βx).
func NewLinearFit ¶
type Sample ¶
type Sample struct { Index int // Index of the sample Time time.Duration // Duration of the sample. }
Sample represents a single benchmark sample.
type Samples ¶
type Samples []Sample
Samples is a list of samples
func (*Samples) AddOrUpdate ¶
Add appends the sample to the list. If there already is a sample with that index, overwrite the duration for it.