I want to profile my tests created with go test -c , but the go tool pprof needs a profile file, usually generated inside a main function like this :
func main() { flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() }
How to create a profile file in my tests?
profiling benchmarking go pprof
tarrsalah
source share