trivialstats

package
v0.0.0-...-4229aae Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package trivialstats implements some basic statistic functions that I keep reimplementing. Notably: counters that track min/max/average, and an implementation of exact percentiles. More sophisticated applications should use ddsketch: https://github.com/DataDog/sketches-go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AverageMinMax

type AverageMinMax struct {
	// contains filtered or unexported fields
}

AverageMinMax computes the average, minimum and maximum of a set of values.

func NewAverageMinMax

func NewAverageMinMax() *AverageMinMax

NewAverageMinMax returns a new empty AverageMinMax.

func (*AverageMinMax) Average

func (a *AverageMinMax) Average() float64

Average returns the average of all records.

func (*AverageMinMax) Count

func (a *AverageMinMax) Count() int64

Count returns the count of records.

func (*AverageMinMax) Max

func (a *AverageMinMax) Max() int64

Max returns the maximum of all records.

func (*AverageMinMax) Min

func (a *AverageMinMax) Min() int64

Min returns the minimum of all records.

func (*AverageMinMax) Record

func (a *AverageMinMax) Record(value int64)

Record adds value to the set.

func (*AverageMinMax) Sum

func (a *AverageMinMax) Sum() int64

Sum returns the sum of all records.

type Distribution

type Distribution struct {
	// contains filtered or unexported fields
}

Distribution records all samples to provide exact percentiles. More serious applications should use https://github.com/DataDog/sketches-go.

func NewDistribution

func NewDistribution() *Distribution

func (*Distribution) Add

func (d *Distribution) Add(sample int64)

func (*Distribution) Stats

func (d *Distribution) Stats() DistributionStats

type DistributionStats

type DistributionStats struct {
	Min   int64
	Max   int64
	Avg   float64
	Count int64

	P1  int64
	P25 int64
	P50 int64
	P75 int64
	P90 int64
	P95 int64
	P99 int64
}

func (DistributionStats) String

func (d DistributionStats) String() string

Jump to

Keyboard shortcuts

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