INNER CODE UNIT · Go
rootWithCPUProfile
runmedev/runme · main.go:35
func rootWithCPUProfile(fn func()) {
if profile := os.Getenv("RUNME_PROFILE_CPU"); profile != "" {
f, err := os.Create(profile)
if err != nil {
fatalf("could not create CPU profile: %v\n", err)
}
defer f.Close()
if err := pprof.StartCPUProfile(f); err != nil {
fatalf("could not start CPU profile: %v\n", err)
}
defer pprof.StopCPUProfile()
}
fn()
if profile := os.Getenv("RUNME_PROFILE_MEM"); profile != "" {
f, err := os.Create(profile)