Golang profiling utility
Introduction
Simple profiling support package for Go.
Inspired by Dave Cheney's library, with extra functionality and automation.
The library can take CPU, Memory, Block, Mutex and Goroutine profiles.
It can either take a single snapshot, or can take snapshots at regular intervals.
Installation
go get github.com/quipo/goprofiler/profiler
Sample usage
package main
import (
"time"
"github.com/quipo/goprofiler/profiler"
)
func main() {
pprofConf := profiler.Config{
Prefix: "/tmp/myapp.",
CPU: true,
Memory: true,
Block: false,
Goroutine: false,
Mutex: false,
Interval: "15s", // one snapshot every 15 seconds,
CPUProfileRate: 100, // collect 100 CPU profiling samples per second
MemoryProfileRate: 1, // collect information about all allocations
MutexProfileRate: 1, // collect information about all blocking events
}
prof := profiler.NewProfiler(pprofConf)
go prof.Run()
// your app's code here...
// you can take a snapshot at any point in the code:
prof.TakeSnapshot()
// take one last snapshot and clean resources
prof.Stop()
}
Useful links
FlameGraph links:
Author
Lorenzo Alberton
Copyright
See LICENSE document