Documentation
¶
Overview ¶
Package average implements sliding time window.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SlidingWindow ¶
SlidingWindow provides a sliding time window with a custom size and granularity to store int64 counters. This can be used to determine the total or unweighted mean average of a subset of the window size.
func MustNew ¶
func MustNew(window, granularity time.Duration) *SlidingWindow
MustNew returns a new SlidingWindow, but panics if an error occurs.
func New ¶
func New(window, granularity time.Duration) (*SlidingWindow, error)
New returns a new SlidingWindow.
func (*SlidingWindow) Add ¶
func (sw *SlidingWindow) Add(v int64)
Add increments the value of the current sample.
func (*SlidingWindow) Average ¶
func (sw *SlidingWindow) Average(window time.Duration) float64
Average returns the unweighted mean of the specified window.
func (*SlidingWindow) Reset ¶
func (sw *SlidingWindow) Reset()
Reset the samples in this sliding time window.
func (*SlidingWindow) Stop ¶
func (sw *SlidingWindow) Stop()
Stop the shifter of this sliding time window. A stopped SlidingWindow cannot be started again.
Click to show internal directories.
Click to hide internal directories.