scalablestats

package module
v0.0.0-...-d219462 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 3 Imported by: 0

README

ScalableStats

ScalableStats is a library to allow collection and processing of metrics with O(1) constant time and space guarantees; this makes it suitable for frequently-sampled metrics such as temperature.

Guarantees are provided by forming a histogram based on apriori knowledge of the data, for example sampled temperatures will lie in the range of 10 to 80'C, quantized to 2'C, ie 35 bins.

Arbitrary percentiles can be extracted from the resultant histogram.

Example

h := NewLinearHistogram(10, 80, 35)

for i := 0; i < 100000; i++ {
    h.Store(rand.Float32() * 80)
}

fmt.Printf("P95=%v\n", h.Percentile(95))
h.Fprint(os.Stdout)
h.CLear()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Histogram

type Histogram struct {
	Thresholds []float32
	Counts     []int
}

func NewLinearHistogram

func NewLinearHistogram(min, max, bins int) *Histogram

func (*Histogram) Clear

func (h *Histogram) Clear()

func (*Histogram) Fprint

func (h *Histogram) Fprint(f *os.File)

func (*Histogram) Percentile

func (h *Histogram) Percentile(threshold int) float32

func (*Histogram) Store

func (h *Histogram) Store(val float32)

Jump to

Keyboard shortcuts

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