3.7.2. pprof包¶
像这个样子:
func main() {
f, err := os.Create(".cpu.prof")
if err != nil {
log.Fatal(err)
}
defer f.Close()
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
do_something()
mem, err := os.Create(".mem.prof")
if err != nil {
log.Fatalln(err.Error())
}
defer mem.Close()
pprof.WriteHeapProfile(mem)
}