ADDED src/0dev.org/debug/pprof/pprof.go Index: src/0dev.org/debug/pprof/pprof.go ================================================================== --- src/0dev.org/debug/pprof/pprof.go +++ src/0dev.org/debug/pprof/pprof.go @@ -0,0 +1,29 @@ +// Package pprof starts various profiling mechanism during initialization +// and provides a function to stop and flush them +package pprof + +import ( + "os" + "runtime/pprof" +) + +var ( + output *os.File +) + +func init() { + output, err := os.Create("cpu.prof") + if err != nil { + os.Stderr.WriteString("Error opening CPU profiling output file.\n" + err.Error()) + return + } + + err = pprof.StartCPUProfile(output) + if err != nil { + os.Stderr.WriteString("Error starting CPU profiling.\n" + err.Error()) + } +} + +func Stop() { + pprof.StopCPUProfile() +}