6
Jul
2021

pprof

06 Jul 2021
Generate reports in app with code: CPU cpuFile, err := os.Create("/tmp/cpuProfile.out") if err != nil { fmt.Println(err) return } pprof.StartCPUProfile(cpuFile) defer pprof.StopCPUProfile() // CODE HERE runtime.GC() Memory memory, err := os.Create("/tmp/memoryProfile.out") if err != nil { fmt.Println(err) return } defer memory.Close() // CODE HERE err = pprof.WriteHeapProfile(memory) if err != nil { fmt.Println(err) return } View reports with go tool pprof
go