【发布时间】:2023-03-20 20:35:01
【问题描述】:
我想profile我由go test -c 生成的基准,但是go tool pprof 需要一个profile 文件,通常在this 之类的主函数中生成:
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
如何在我的基准测试中创建配置文件?
【问题讨论】:
标签: go profiling benchmarking pprof