Skip to content

Fine grained (μs) timings for arbitrary actions which can be reported on during runtime.

License

Notifications You must be signed in to change notification settings

domdavis/gomeasure

Repository files navigation

Measurement and Instrumentation package for Go

Build Status Coverage Status Maintainability

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.

Installation

go get github.com/domdavis/gomeasure

Usage

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()

Actions

Segregated sets of actions can be created if required:

a := gomeasure.NewActions()
t := a.TimerFor("my action")
t.Stop()
fmt.Println(a.Snapshot())

About

Fine grained (μs) timings for arbitrary actions which can be reported on during runtime.

Resources

License

Stars

Watchers

Forks

Packages

No packages published