sliding_window

package
v0.0.0-...-b03bf0d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SlidingWindow

type SlidingWindow struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func MustNew

func MustNew(window, granularity time.Duration) *SlidingWindow

func New

func New(window, granularity time.Duration) (*SlidingWindow, error)

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) Stop

func (sw *SlidingWindow) Stop()

Stop the shifter of this sliding time window. A stopped SlidingWindow cannot be started again.

func (*SlidingWindow) Total

func (sw *SlidingWindow) Total(window time.Duration) (int64, int)

Total returns the sum of all values over the specified window, as well as the number of samples.

Jump to

Keyboard shortcuts

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