hdrhistogram: github.com/codahale/hdrhistogram Index | Files

package hdrhistogram

import "github.com/codahale/hdrhistogram"

Package hdrhistogram provides an implementation of Gil Tene's HDR Histogram data structure. The HDR Histogram allows for fast and accurate analysis of the extreme ranges of data with non-normal distributions, like latency.

Index

Package Files

hdr.go window.go

type Bar Uses

type Bar struct {
    From, To, Count int64
}

Histogram bar for plotting

func (Bar) String Uses

func (b Bar) String() string

Pretty print as csv for easy plotting

type Bracket Uses

type Bracket struct {
    Quantile       float64
    Count, ValueAt int64
}

A Bracket is a part of a cumulative distribution.

type Histogram Uses

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

A Histogram is a lossy data structure used to record the distribution of non-normally distributed data (like latency) with a high degree of accuracy and a bounded degree of precision.

func Import Uses

func Import(s *Snapshot) *Histogram

Import returns a new Histogram populated from the Snapshot data (which the caller must stop accessing).

func New Uses

func New(minValue, maxValue int64, sigfigs int) *Histogram

New returns a new Histogram instance capable of tracking values in the given range and with the given amount of precision.

func (*Histogram) ByteSize Uses

func (h *Histogram) ByteSize() int

ByteSize returns an estimate of the amount of memory allocated to the histogram in bytes.

N.B.: This does not take into account the overhead for slices, which are small, constant, and specific to the compiler version.

func (*Histogram) CumulativeDistribution Uses

func (h *Histogram) CumulativeDistribution() []Bracket

CumulativeDistribution returns an ordered list of brackets of the distribution of recorded values.

func (*Histogram) Distribution Uses

func (h *Histogram) Distribution() (result []Bar)

Distribution returns an ordered list of bars of the distribution of recorded values, counts can be normalized to a probability

func (*Histogram) Equals Uses

func (h *Histogram) Equals(other *Histogram) bool

Equals returns true if the two Histograms are equivalent, false if not.

func (*Histogram) Export Uses

func (h *Histogram) Export() *Snapshot

Export returns a snapshot view of the Histogram. This can be later passed to Import to construct a new Histogram with the same state.

func (*Histogram) HighestTrackableValue Uses

func (h *Histogram) HighestTrackableValue() int64

HighestTrackableValue returns the upper bound on values that will be added to the histogram

func (*Histogram) LowestTrackableValue Uses

func (h *Histogram) LowestTrackableValue() int64

LowestTrackableValue returns the lower bound on values that will be added to the histogram

func (*Histogram) Max Uses

func (h *Histogram) Max() int64

Max returns the approximate maximum recorded value.

func (*Histogram) Mean Uses

func (h *Histogram) Mean() float64

Mean returns the approximate arithmetic mean of the recorded values.

func (*Histogram) Merge Uses

func (h *Histogram) Merge(from *Histogram) (dropped int64)

Merge merges the data stored in the given histogram with the receiver, returning the number of recorded values which had to be dropped.

func (*Histogram) Min Uses

func (h *Histogram) Min() int64

Min returns the approximate minimum recorded value.

func (*Histogram) RecordCorrectedValue Uses

func (h *Histogram) RecordCorrectedValue(v, expectedInterval int64) error

RecordCorrectedValue records the given value, correcting for stalls in the recording process. This only works for processes which are recording values at an expected interval (e.g., doing jitter analysis). Processes which are recording ad-hoc values (e.g., latency for incoming requests) can't take advantage of this.

func (*Histogram) RecordValue Uses

func (h *Histogram) RecordValue(v int64) error

RecordValue records the given value, returning an error if the value is out of range.

func (*Histogram) RecordValues Uses

func (h *Histogram) RecordValues(v, n int64) error

RecordValues records n occurrences of the given value, returning an error if the value is out of range.

func (*Histogram) Reset Uses

func (h *Histogram) Reset()

Reset deletes all recorded values and restores the histogram to its original state.

func (*Histogram) SignificantFigures Uses

func (h *Histogram) SignificantFigures() int64

SignificantFigures returns the significant figures used to create the histogram

func (*Histogram) StdDev Uses

func (h *Histogram) StdDev() float64

StdDev returns the approximate standard deviation of the recorded values.

func (*Histogram) TotalCount Uses

func (h *Histogram) TotalCount() int64

TotalCount returns total number of values recorded.

func (*Histogram) ValueAtQuantile Uses

func (h *Histogram) ValueAtQuantile(q float64) int64

ValueAtQuantile returns the recorded value at the given quantile (0..100).

type Snapshot Uses

type Snapshot struct {
    LowestTrackableValue  int64
    HighestTrackableValue int64
    SignificantFigures    int64
    Counts                []int64
}

A Snapshot is an exported view of a Histogram, useful for serializing them. A Histogram can be constructed from it by passing it to Import.

type WindowedHistogram Uses

type WindowedHistogram struct {
    Current *Histogram
    // contains filtered or unexported fields
}

A WindowedHistogram combines histograms to provide windowed statistics.

func NewWindowed Uses

func NewWindowed(n int, minValue, maxValue int64, sigfigs int) *WindowedHistogram

NewWindowed creates a new WindowedHistogram with N underlying histograms with the given parameters.

func (*WindowedHistogram) Merge Uses

func (w *WindowedHistogram) Merge() *Histogram

Merge returns a histogram which includes the recorded values from all the sections of the window.

func (*WindowedHistogram) Rotate Uses

func (w *WindowedHistogram) Rotate()

Rotate resets the oldest histogram and rotates it to be used as the current histogram.

Package hdrhistogram imports 2 packages (graph) and is imported by 309 packages. Updated 2020-07-24. Refresh now. Tools for package owners.