import "go.chromium.org/luci/common/tsmon/distribution"
Package distribution contains distribution metrics, fixed width and geometric bucketers.
var DefaultBucketer = GeometricBucketer(math.Pow(10, 0.2), 100)
DefaultBucketer is a bucketer with sensible bucket sizes.
type Bucketer struct {
// contains filtered or unexported fields
}
A Bucketer maps samples into discrete buckets.
FixedWidthBucketer returns a Bucketer that uses numFiniteBuckets+2 buckets:
bucket[0] covers (-Inf...0) bucket[i] covers [width*(i-1)...width*i) for i > 0 and i <= numFiniteBuckets bucket[numFiniteBuckets+1] covers [width*numFiniteBuckets...+Inf)
The width must be greater than 0, and the number of finite buckets must be greater than 0.
GeometricBucketer returns a Bucketer that uses numFiniteBuckets+2 buckets:
bucket[0] covers (−Inf, 1) bucket[i] covers [growthFactor^(i−1), growthFactor^i) for i > 0 and i <= numFiniteBuckets bucket[numFiniteBuckets+1] covers [growthFactor^(numFiniteBuckets−1), +Inf)
growthFactor must be positive, and the number of finite buckets must be greater than 0.
NewBucketer creates a bucketer from custom parameters.
Bucket returns the index of the bucket for sample. TODO(dsansome): consider reimplementing sort.Search inline to avoid overhead of calling a function to compare two values.
GrowthFactor returns the growth factor used to configure this Bucketer.
NumBuckets returns the number of buckets including the underflow and overflow buckets.
NumFiniteBuckets returns the number of finite buckets.
OverflowBucket returns the index of the overflow bucket.
UnderflowBucket returns the index of the underflow bucket.
Width returns the bucket width used to configure this Bucketer.
type Distribution struct {
// contains filtered or unexported fields
}
A Distribution holds a statistical summary of a collection of floating-point values.
func New(b *Bucketer) *Distribution
New creates a new distribution using the given bucketer. Passing a nil Bucketer will use DefaultBucketer.
func (d *Distribution) Add(sample float64)
Add adds the sample to the distribution and updates the statistics.
func (d *Distribution) Bucketer() *Bucketer
Bucketer returns the bucketer used in this distribution.
func (d *Distribution) Buckets() []int64
Buckets provides access to the underlying buckets slice. len(Buckets) will be <= Bucketer().NumBuckets()
func (d *Distribution) Count() int64
Count returns the number of times Add has been called.
func (d *Distribution) LastNonZeroBucket() int
LastNonZeroBucket returns the index into Buckets() of the last bucket that is set (non-zero). Returns -1 if Count() == 0.
func (d *Distribution) Sum() float64
Sum returns the sum of all samples passed to Add.
Package distribution imports 3 packages (graph) and is imported by 28 packages. Updated 2019-12-06. Refresh now. Tools for package owners.