gomeasure
is designed to provide fine grained (μs) timings for arbitrary
actions which can be reported on during runtime. Actions are named, and metrics
for all actions of the same name can be queried at any time.
go get github.com/domdavis/gomeasure
Recording an action is simply a case of:
t := gomeasure.Action("my action")
// Do something
t.Stop()
A set of Stats can then be retrieved using the same name:
s := gomeasure.Report("my action")
The returned Stats provide timings as time.Duration
, which provides ns
results, however, the overhead for starting and stopping a timer is ~750ns
making the results accurate to μs granularity.
A full report on all actions being measured is provided using:
r := gomeasure.Snapshot()
Segregated sets of actions can be created if required:
a := gomeasure.NewActions()
t := a.TimerFor("my action")
t.Stop()
fmt.Println(a.Snapshot())