go_command_tutorial icon indicating copy to clipboard operation
go_command_tutorial copied to clipboard

使用go tool pprof工具输出的结果是空

Open workhardcc opened this issue 10 years ago • 3 comments

您好,为啥我在main函数里添加了如下代码后,用go tool pprof工具输出的结果是空啊?生成的prof文件只有64B... func main(){ flag.Parse() if _cpuprofile != "" { // 根据命令行指定文件名创建 profile 文件 f, err := os.Create(_cpuprofile) if err != nil { log.Fatal(err) } // 开启 CPU profiling pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } . . . } 输出结果如下

go tool pprof metrics_prof mytest.prof Entering interactive mode (type "help" for commands) (pprof) list Total: 0 (pprof) top 0 of 0 total ( 0%) flat flat% sum% cum cum% (pprof) q

workhardcc avatar Mar 09 '16 15:03 workhardcc

两种可能:程序基本没用CPU,或者你采样的时间太短。

hyper0x avatar Mar 17 '16 07:03 hyper0x

这个issue我暂且关闭。如有需要你可以再次开启。

hyper0x avatar Mar 22 '16 06:03 hyper0x

谢谢!

workhardcc avatar Apr 22 '16 03:04 workhardcc