timeheap

package
v0.0.0-...-15a9106 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 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) Clear

func (h *TimeHeap) Clear()

Clear removes all elements from the container.

Jump to

Keyboard shortcuts

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