timer

package
v0.5.46 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 1 Imported by: 6 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package timer provides a simple wall-clock duration timer based on standard time. It 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 {

	// the most recent starting time
	St time.Time

	// the total accumulated time
	Total time.Duration

	// the number of start/stops
	N int
}

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

func (t *Time) Reset()

Reset resets the overall accumulated Total and N counters and start time to zero

func (*Time) ResetStart

func (t *Time) ResetStart()

ResetStart reset then start the timer

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

Jump to

Keyboard shortcuts

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