timings
import "codeberg.org/mgkeller/go-timings"
Overview
Example :
someLogger := log.New(io.Discard, "[TIMING]", 0)
f := func() {
defer Track("MyFunc", time.Now(), someLogger)
// Do stuff here
}
f()
// someLogger will have the timing for the function
Index
Examples
Package files
timings.go
func Now() time.Time
Now is equivalent to time.Now(), but saves the import of "time" if
it's not otherwise needed
func Track(name string, start time.Time, l *log.Logger)
Track tracks how long a function takes, to a log.Logger
e.g. make the first line
defer Track("func_name", time.Now(), logger).
func TrackErr(name string, start time.Time)
TrackErr tracks how long a function takes, to Stderr
e.g. make the first line:
defer Trackerr("func_name", time.Now()).
func TrackOut(name string, start time.Time)
TrackOut tracks how long a function takes, to Stdout
e.g. make the first line:
defer TrackOut("func_name", time.Now()).
type Tracker struct {
// contains filtered or unexported fields
}
Tracker is a simple device to track timings
func (t *Tracker) Duration() time.Duration
Duration returns the Duration of time between Start() and Stop()
func (*Tracker) Since
func (t *Tracker) Since() time.Duration
Since returns a Duration since the start time
func (*Tracker) Start
func (t *Tracker) Start()
Start records the start time
func (*Tracker) Stop
func (t *Tracker) Stop()
Stop records the end time
Generated by godoc2md