metrics

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Time

func Time(f func()) time.Duration

Time runs the given function and returns the interval required to run.

Types

type Timer

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

Timer measures time intervals.

func (*Timer) Interval

func (t *Timer) Interval() time.Duration

Interval returns the elapsed time interval. Calling Interval on a Timer that has never run will always return zero. Calling Interval on a running timer will return the interval from the start time to now. Calling Interval on a stopped timer will always return the interval of the last run.

func (*Timer) Reset

func (t *Timer) Reset()

Reset will clear the timer if it is not running. Calling Reset on a running timer does nothing.

func (*Timer) Running

func (t *Timer) Running() bool

Running returns true if this timer is currently running.

func (*Timer) Start

func (t *Timer) Start()

Start begins the timer (if it is not already running) and clears any previous values.

func (*Timer) Stop

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

Stop ends the timer and returns the elaspsed interval. Calling Stop on a Timer that has never run will always return zero, and calling Stop on a completed timer will return the previous value.

type Timing

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

func NewTiming

func NewTiming() *Timing

func (*Timing) Delete

func (t *Timing) Delete(name string)

Delete removes the named timer.

func (*Timing) Do

func (t *Timing) Do(f func(string, *Timer))

Do calls f for each timer.

func (*Timing) Interval

func (t *Timing) Interval(name string) time.Duration

Interval returns the elapsed time interval for the named timer. The result is zero if the named timer doesn't exist. Calling Interval on a running timer will return the interval from the start time to now. Calling Interval on a stopped timer will always return the interval of the last run.

func (*Timing) Reset

func (t *Timing) Reset(name string)

Reset will clear the named timer if it is not running. Calling Reset on a running timer does nothing.

func (*Timing) ResetAll

func (t *Timing) ResetAll()

ResetAll will clear all the timers.

func (*Timing) Running

func (t *Timing) Running(name string) bool

Running returns true if the name timer is currently running. The result is false if the named timer doesn't exit.

func (*Timing) Start

func (t *Timing) Start(name string)

Start begins the named timer (if it is not already running) and clears any previous values. If the named timer doesn't exist it a new one be created and started.

func (*Timing) Stop

func (t *Timing) Stop(name string) time.Duration

Stop ends the named timer and returns the elaspsed interval. The result is zero if the named timer doesn't exist. Calling Stop on a completed timer will return the previous value.

Jump to

Keyboard shortcuts

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