timer

package
v0.0.0-...-531e5d3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Overview

Package timer provides a simple wall-clock duration timer based on standard time. Accumulates total and average over multiple Start / Stop intervals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Time

type Time struct {
	St    time.Time     `desc:"the most recent starting time"`
	Total time.Duration `desc:"the total accumulated time"`
	N     int           `desc:"the number of start/stops"`
}

Time manages the timer accumulated time and count

func (*Time) Avg

func (t *Time) Avg() time.Duration

Avg returns the average start / stop interval (assumes each was measuring the same thing).

func (*Time) AvgSecs

func (t *Time) AvgSecs() float64

AvgSecs returns the average start / stop interval (assumes each was measuring the same thing) as a float64 of seconds

func (*Time) Reset

func (t *Time) Reset()

Reset resets the overall accumulated Total and N counters

func (*Time) Start

func (t *Time) Start()

Start starts the timer

func (*Time) Stop

func (t *Time) Stop() time.Duration

Stop stops the timer and accumulates the latest start - stop interval, and also returns it

func (*Time) TotalSecs

func (t *Time) TotalSecs() float64

TotalSecs returns the total start / stop intervals as a float64 of seconds.

Jump to

Keyboard shortcuts

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