Skip to content

najeira/measure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

measure

Usage

Measure

Add measure to your code.

import "github.com/najeira/measure"

func foo() {
    defer measure.Start("foo").Stop()

    // your code

}

or

...
m := measure.Start("foo")
// your code
m.Stop()
...

Stats

Get statistics.

stats := measure.GetStats()
stats.SortDesc("sum")

// print stats in CSV format
for _, s := range stats {
	fmt.Fprintf(w, "%s,%d,%f,%f,%f,%f,%f,%f\n",
		s.Key, s.Count, s.Sum, s.Min, s.Max, s.Avg, s.Rate, s.P95)
}

Reset statistics.

measure.Reset()

Metrics

You can handle multiple metrics.

var metricsA = measure.NewMetrics()
var metricsB = measure.NewMetrics()

func foo() {
    defer metricsA.Start("foo").Stop()
}

func bar() {
    defer metricsB.Start("bar").Stop()
}

License

MIT

About

Measure and aggregate processing time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages