timing

package
v0.0.0-...-f33e45f Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlignedTicker

type AlignedTicker struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

func NewAlignedTicker

func NewAlignedTicker(interval time.Duration) *AlignedTicker

func (*AlignedTicker) Stop

func (at *AlignedTicker) Stop()

Stop the AlignedTicker from generating any more ticks on its channel. Like time.Ticker.Stop() and time.Timer.Stop(), does not close the public channel, so that a read on the channel won't unblock.

type Chrono

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

func StartChrono

func StartChrono() Chrono

Start a chrono now

func (Chrono) Duration

func (t Chrono) Duration() time.Duration

func (Chrono) Finish

func (t Chrono) Finish() float64

Finish a chrono and return the elapsed time in milliseconds

func (Chrono) FinishDur

func (t Chrono) FinishDur() time.Duration

Finish a chrono and return the elapsed time as a time.Duration

type JitterTicker

type JitterTicker struct {
	C <-chan time.Time // The channel on which the ticks are delivered.
	// contains filtered or unexported fields
}

func NewJitterTicker

func NewJitterTicker(d time.Duration, windowStart uint, windowEnd uint) *JitterTicker

Creates a jittered ticker windowStart and windowEnd specify the jitter range relative to the d interval For example, with d=1000ms start=80 and end=120, the first tick will happen after a random delay between 800ms and 1200ms. Subsequent ticks will happen every 1000ms.

func (*JitterTicker) Stop

func (t *JitterTicker) Stop()

Stop turns off a ticker. After Stop, no more ticks will be sent. Stop does not close the channel, to prevent a read from the channel succeeding incorrectly.

Jump to

Keyboard shortcuts

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