timer

package
v0.90.16 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// TotalTimeElapsed is a constant string value to denote total time elapsed.
	TotalTimeElapsed = "Total"
)

Variables

This section is empty.

Functions

func LogSummary

func LogSummary()

LogSummary prints the summary of all the times collected so far into the INFO section.

func StartTimer

func StartTimer(key string)

StartTimer initiailzes the timer object with the current timestamp information.

func StopTimer

func StopTimer(key string)

StopTimer records the duration for the current stage sent as the key parameter and stores the information.

Types

type Timer

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

Timer is the struct that keeps track of each of the sections.

func NewTimer

func NewTimer() Timer

NewTimer returns a new timer that can be used to track sections and

func (*Timer) LogSummary

func (t *Timer) LogSummary(logger *logrus.Logger)

LogSummary prints the summary of all the times collected so far into the INFO section. The format of printing will be the following: If there are no stages except the total time stage, then it only prints the following Time elapsed: <x>m<yy>s If there are multiple stages, it prints the following: Time elapsed for each section Stage1: <x>m<yy>s Stage2: <x>m<yy>s . . . StageN: <x>m<yy>s Time elapsed: <x>m<yy>s All durations printed are rounded up to the next second value and printed in the format mentioned above.

func (*Timer) StartTimer

func (t *Timer) StartTimer(key string)

StartTimer initializes the timer object with the current timestamp information.

func (*Timer) StopTimer

func (t *Timer) StopTimer(key string) time.Duration

StopTimer records the duration for the current stage sent as the key parameter and stores the information.

Jump to

Keyboard shortcuts

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