Documentation
¶
Index ¶
- type Stopwatch
- func (sw *Stopwatch) CurrentSegmentDuration() time.Duration
- func (sw *Stopwatch) IsRunning() bool
- func (sw *Stopwatch) IsStopped() bool
- func (sw *Stopwatch) MakeSplit() (lapTime, totalTime time.Duration)
- func (sw *Stopwatch) ReadingTime() time.Time
- func (sw *Stopwatch) Reset()
- func (sw *Stopwatch) Restart()
- func (sw *Stopwatch) Resume()
- func (sw *Stopwatch) StartTime() time.Time
- func (sw *Stopwatch) Stop() time.Duration
- func (sw *Stopwatch) StopTime() time.Time
- func (sw *Stopwatch) TakeLapTime() time.Duration
- func (sw *Stopwatch) TotalTime() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stopwatch ¶
type Stopwatch struct {
// contains filtered or unexported fields
}
Stopwatch implements a stopwatch which can be stopped, resumed and reset and can report its current reading of time with TotalTime() as well as allow for convenient measuring of consecutive intervals using TakeLapTime().
func NewStartedStopwatch ¶
func NewStartedStopwatch() *Stopwatch
NewStartedStopwatch returns a started stopwatch, ready to report TotalTime() and TakeLapTime().
func NewStoppedStopwatch ¶
func NewStoppedStopwatch() *Stopwatch
NewStoppedStopwatch returns a stopwatch which needs to have Restart() or Resume() called on it in order to begin counting time.
func (*Stopwatch) CurrentSegmentDuration ¶
CurrentSegmentDuration returns the duration since the stopwatch was last started/restarted, reset, resumed or had LapTime() called.
func (*Stopwatch) MakeSplit ¶
MakeSplit does the same as TakeLapTime(), but also returns the exact according total time.
func (*Stopwatch) ReadingTime ¶
ReadingTime returns the time at which the stopwatch was last started/restarted, reset or had LapTime() called.
func (*Stopwatch) Reset ¶
func (sw *Stopwatch) Reset()
Reset sets the stopwatch reading back to zero.
func (*Stopwatch) Restart ¶
func (sw *Stopwatch) Restart()
Restart resets and resumes the stopwatch.
func (*Stopwatch) Resume ¶
func (sw *Stopwatch) Resume()
Resume resumes the stopwatch when it is stopped.
func (*Stopwatch) StartTime ¶
StartTime returns the time at which the stopwatch was last started/restarted, reset or resumed.
func (*Stopwatch) Stop ¶
Stop stops the stopwatch, causing it to stop observing the passing of time. It can be resumed with Resume().
func (*Stopwatch) StopTime ¶
StopTime returns the time at which the stopwatch was last stopped, started/restarted or reset.
func (*Stopwatch) TakeLapTime ¶
TakeLapTime makes a split, returning the change in TotalTime() since last calling this function or starting/restarting or resetting the stopwatch.