Documentation ¶
Index ¶
- type Histogram
- func (h *Histogram) Add(other Histogram)
- func (h Histogram) Delta(other Histogram) Histogram
- func (h Histogram) Mean() uint64
- func (h Histogram) Report() string
- func (h *Histogram) Sample(v uint64)
- func (h *Histogram) SampleLen(l int)
- func (h *Histogram) SampleTimeSince(t time.Time)
- func (h Histogram) Samples() uint64
- func (h Histogram) String() string
- func (h Histogram) Sum() uint64
- type ToStringFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Histogram ¶
type Histogram struct { ToString ToStringFunc // contains filtered or unexported fields }
Histogram is a shameless and low-rent knock of the chromium project's histogram:
https://chromium.googlesource.com/chromium/src/base/+/master/metrics/histogram.h
It logically stores a running histogram of uint64 values and shares some important features of its inspiration:
- It acccepts a correctness deficit in return for not needing to lock. IOW, concurrent calls to Sample may clobber each other.
- It trades compactness and ease of arithmatic across histograms for precision. Samples lose precision up to the range of the values which are stored in a bucket
Only implemented: Log2-based histogram
func NewByteHistogram ¶
func NewByteHistogram() Histogram
NewByteHistogram stringifies values using humanize over byte values
func NewTimeHistogram ¶
func NewTimeHistogram() Histogram
func (*Histogram) Add ¶
Add returns a new Histogram which is the result of adding this and other bucket-wise.
func (Histogram) Delta ¶
Delta returns a new Histogram which is the result of subtracting other from this bucket-wise. The intent is to capture changes in the state of histogram which is collecting samples over some time period. It will panic if any bucket from other is larger than the corresponding bucket in this.
func (Histogram) Report ¶
Report returns an ASCII graph of the non-zero range of normalized buckets. IOW, it returns a basic graph of the histogram
func (*Histogram) SampleLen ¶
SampleLen is a convenience wrapper around Sample which internally type asserts the int to a uint64
func (*Histogram) SampleTimeSince ¶
SampleTimeSince is a convenience wrapper around Sample which takes the duration since |t|, if 0, rounds to 1 and passes to Sample() as an uint64 number of nanoseconds.