stats

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2017 License: Apache-2.0 Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	Count int64
	Min   float64
	Max   float64
	Sum   float64
	// contains filtered or unexported fields
}

Counter is a type whose instances record values and calculate stats (count,average,min,max,stddev).

func (*Counter) Avg

func (c *Counter) Avg() float64

Avg returns the average.

func (*Counter) Log

func (c *Counter) Log(msg string)

Log outputs the stats to the logger.

func (*Counter) Print

func (c *Counter) Print(out io.Writer, msg string)

Print prints stats.

func (*Counter) Record

func (c *Counter) Record(v float64)

Record records a data point.

func (*Counter) Reset

func (c *Counter) Reset()

Reset clears the counter to reset it to original 'no data' state.

func (*Counter) StdDev

func (c *Counter) StdDev() float64

StdDev returns the standard deviation.

func (*Counter) Transfer

func (c *Counter) Transfer(src *Counter)

Transfer merges the data from src into this Counter and clears src.

type Histogram

type Histogram struct {
	Counter
	Offset  float64 // offset applied to data before fitting into buckets
	Divider float64 // divider applied to data before fitting into buckets
	// Don't access directly (outside of this package):
	Hdata []int32 // n+1 buckets (for last one)
}

Histogram extends Counter and adds an histogram. Must be created using NewHistogram or anotherHistogram.Clone() and not directly.

func NewHistogram

func NewHistogram(Offset float64, Divider float64) *Histogram

NewHistogram creates a new histogram (sets up the buckets).

func (*Histogram) CalcPercentile

func (h *Histogram) CalcPercentile(percentile float64) float64

CalcPercentile returns the value for an input percentile e.g. for 90. as input returns an estimate of the original value threshold where 90.0% of the data is below said threshold.

func (*Histogram) Clone

func (h *Histogram) Clone() *Histogram

Clone returns a copy of the histogram.

func (*Histogram) CopyFrom

func (h *Histogram) CopyFrom(src *Histogram)

CopyFrom sets the content of this object to a copy of the src.

func (*Histogram) Log

func (h *Histogram) Log(msg string, percentile float64)

Log Logs the histogram to the counter.

func (*Histogram) Print

func (h *Histogram) Print(out io.Writer, msg string, percentile float64)

Print dumps the histogram (and counter) to the provided writer. Also calculates the percentile.

func (*Histogram) Record

func (h *Histogram) Record(v float64)

Record records a data point.

func (*Histogram) Reset

func (h *Histogram) Reset()

Reset clears the data. Reset it to NewHistogram state.

func (*Histogram) Transfer

func (h *Histogram) Transfer(src *Histogram)

Transfer merges the data from src into this Histogram and clears src.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL