Documentation ¶
Overview ¶
Package perf exposes a centralized API for storing, tracking, and querying performance data for a Go application.
Index ¶
- Constants
- func DumpString() string
- type Counter
- func (this *Counter) Add(amount int64)
- func (this *Counter) DisableStats()
- func (this *Counter) EnableStats()
- func (this *Counter) Increment()
- func (this *Counter) MaxPerSec() int64
- func (this *Counter) PerSec() int64
- func (this *Counter) Reset()
- func (this *Counter) Set(val int64)
- func (this *Counter) Stats() *Stat
- func (this *Counter) String() string
- func (this *Counter) Value() int64
- type CounterSet
- func (this *CounterSet) Add(offset int, val int64)
- func (this *CounterSet) CounterName(offset int) string
- func (this *CounterSet) EnableStats(offset int)
- func (this *CounterSet) Get(offset int) *Counter
- func (this *CounterSet) Increment(offset int)
- func (this *CounterSet) Len() int
- func (this *CounterSet) Name() string
- func (this *CounterSet) Reset()
- func (this *CounterSet) Set(offset int, value int64)
- func (this *CounterSet) String() string
- func (this *CounterSet) Value(offset int) int64
- type CounterVals
- type Snapshot
- type Stat
Constants ¶
const STAT_SAMPLES = 100
The number of samples stored and used to calculate statistics in a given Stat object.
Variables ¶
This section is empty.
Functions ¶
func DumpString ¶
func DumpString() string
DumpString dumps every value, of every Counter, of every CounterSet registered with the perf service, in string format.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter represents a simple performance counter object. Counters tracking an ongoing value while also tracking the min, max and per-second delta between samples. Addtionally, statistics can be enabled on a counter object to enable tracking of variance, mean, median and standard deviation.
func NewCounter ¶
func NewCounter() *Counter
NewCounter initializes a new Counter object and returns a pointer to it for use.
func (*Counter) Add ¶
Add adds calculates a new counter value by adding the supplied amount to the counter's current value.
func (*Counter) DisableStats ¶
func (this *Counter) DisableStats()
DisableStats removes statistical tracking on this counter object.
func (*Counter) EnableStats ¶
func (this *Counter) EnableStats()
EnableStats enables statistical tracking on this counter object. Note that stats tracking is expensive and should be enabled judiciously on applications that have many counters.
func (*Counter) Increment ¶
func (this *Counter) Increment()
Increment calculates and inserts a new NextVal() which is 1 greater than the last value.
func (*Counter) MaxPerSec ¶
MaxPerSec calculates and returns the per-second derivative from the most recent two samples.
func (*Counter) PerSec ¶
PerSec calculates and returns the per-second derivative from the most recent two samples.
func (*Counter) Reset ¶
func (this *Counter) Reset()
Reset re-initializes the counter object and underlying stats. It does not disable stats if they have been enabled on the counter object, only resets them.
func (*Counter) Stats ¶
Stats returns this counter object's statistics object. If stats are not enabled, returns nil.
type CounterSet ¶
type CounterSet struct {
// contains filtered or unexported fields
}
CounterSet represent a collection of named performance CounterSet and their values.
func GetAllCounterSets ¶
func GetAllCounterSets() []*CounterSet
GetAllCounterSets returns a slice with pointers to all registered CounterSet objects.
func GetCounterSet ¶
func GetCounterSet(name string) *CounterSet
GetCounterSet returns the named CounterSet object, if one is registered by that name. Otherwise, nil is returned.
func NewCounterSet ¶
func NewCounterSet(name string, size int, names []string) *CounterSet
NewCounterSet is a construction helper which creates a new CounterSet container, registers and initializes it, and returns a pointer to it for use.
func (*CounterSet) Add ¶
func (this *CounterSet) Add(offset int, val int64)
Add adds the supplied val to the value of the specified counter. If the specified offset doesn't exist, it's a no-op.
func (*CounterSet) CounterName ¶
func (this *CounterSet) CounterName(offset int) string
CounterName returns the friendly name of the counter at the given offset. If the specified offset doesn't exist, a blank string is returned.
func (*CounterSet) EnableStats ¶
func (this *CounterSet) EnableStats(offset int)
EnableStats enables statistics gathering on the given counter object.
func (*CounterSet) Get ¶
func (this *CounterSet) Get(offset int) *Counter
Get returns the Counter object representing the given offset.
func (*CounterSet) Increment ¶
func (this *CounterSet) Increment(offset int)
Increment adds 1 to the value of the specified counter. If the specified offset doesn't exist, it's a no-op.
func (*CounterSet) Len ¶
func (this *CounterSet) Len() int
Len returns the number of counters in available in this CounterSet.
func (*CounterSet) Name ¶
func (this *CounterSet) Name() string
Name returns the friendly name of this CounterSet container.
func (*CounterSet) Reset ¶
func (this *CounterSet) Reset()
Reset ranges through all individual CounterSet in this CounterSet object and sets them all back to zero.
func (*CounterSet) Set ¶
func (this *CounterSet) Set(offset int, value int64)
Set sets the value of the counter at the given offset to the specified value. If the specified offset doesn't exist, it's a no-op
func (*CounterSet) String ¶
func (this *CounterSet) String() string
String returns a friendly representation of all the values stored in this CounterSet object.
func (*CounterSet) Value ¶
func (this *CounterSet) Value(offset int) int64
Value returns the current value of the counter at the given offset. If the offset doesn't exist, zero is returned.
type CounterVals ¶
type CounterVals struct { Max int64 MaxPerSec int64 Mean float64 Min int64 Name string PerSec int64 StdDev float64 Value int64 Variance float64 }
CounterVals represents all of the values associated with a given counter.
func (*CounterVals) String ¶
func (this *CounterVals) String() string
String pretty-prints the values inside the CounterVals object.
func (*CounterVals) StringBrief ¶
func (this *CounterVals) StringBrief() string
StringBrief prints a less verbose output of performance counters, only writing data for non-default values.
type Snapshot ¶
type Snapshot struct { Counters []*CounterVals Timestamp time.Time }
Snapshot represents a snapshot of perf counter data taken at a given point in time.
func TakeSnapshot ¶
func TakeSnapshot() *Snapshot
TakeSnapshot creates a new Snapshot object containing the values of all the current metrics in the perf system, and returns a pointer to it for use.
func (*Snapshot) String ¶
String pretty-prints the Snapshot object and all of the counter objects it contains.
func (*Snapshot) StringBrief ¶
StringBrief pretty-prints a less verbose version of the Snapshot object, opting to only print non-default values.
type Stat ¶
type Stat struct {
// contains filtered or unexported fields
}
Stat represents a series of values and some common statistical values associated with that set.
func NewStat ¶
func NewStat() *Stat
NewStat initializes a new Stat object and returns a pointer to it for use.
func (*Stat) Max ¶
Max returns the maximum value that has been observed since recording stats for this object.
func (*Stat) Min ¶
Min returns the minimum value that has been observed since reocrding stats for this object.