3 // A WindowedHistogram combines histograms to provide windowed statistics.
4 type WindowedHistogram struct {
12 // NewWindowed creates a new WindowedHistogram with N underlying histograms with
13 // the given parameters.
14 func NewWindowed(n int, minValue, maxValue int64, sigfigs int) *WindowedHistogram {
15 w := WindowedHistogram{
17 h: make([]Histogram, n),
18 m: New(minValue, maxValue, sigfigs),
22 w.h[i] = *New(minValue, maxValue, sigfigs)
29 // Merge returns a histogram which includes the recorded values from all the
30 // sections of the window.
31 func (w *WindowedHistogram) Merge() *Histogram {
33 for _, h := range w.h {
39 // Rotate resets the oldest histogram and rotates it to be used as the current
41 func (w *WindowedHistogram) Rotate() {
43 w.Current = &w.h[w.idx%len(w.h)]