timeheap

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeHeap

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

TimeHeap implements a heap sorted by time, where older elements are popped during AveragePerSecond call.

func NewTimeHeap

func NewTimeHeap() *TimeHeap

NewTimeHeap creates a new TimeHeap object.

func (*TimeHeap) Add

func (h *TimeHeap) Add(count uint64)

Add a new entry to the container with a count for the average calculation.

func (*TimeHeap) AveragePerSecond

func (h *TimeHeap) AveragePerSecond(timeBefore time.Duration) float32

AveragePerSecond calculates the average per second of all entries in the given duration. older elements are removed from the container.

func (TimeHeap) Len

func (h TimeHeap) Len() int

func (TimeHeap) Less

func (h TimeHeap) Less(i, j int) bool

func (*TimeHeap) Pop

func (h *TimeHeap) Pop() interface{}

func (*TimeHeap) Push

func (h *TimeHeap) Push(x interface{})

func (TimeHeap) Swap

func (h TimeHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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