Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

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

Releases

No releases published

Packages

No packages published

Languages