我的主块中有以下内容:
func main() {
defer profile.Start().Stop()
fmt.Println("running version", version, "built on", date)
fmt.Println()
cmd.Execute()
time.Sleep(2 * time.Second)
}
cmd
cobra 子命令在哪里。我做了一个 go build,然后我运行二进制文件。我可以看到它生成了一个pprof
文件:
2018/09/13 18:43:26 profile: cpu profiling enabled, /tmp/profile705487093/cpu.pprof
... output deleted ...
2018/09/13 18:43:31 profile: cpu profiling disabled, /tmp/profile705487093/cpu.pprof
然后我试图分析它,使用:
go tool pprof /root/code/debug/evented /tmp/profile705487093/cpu.pprof
但是当 pprof 打开时,我看到了这个:
File: evented
Type: cpu
Time: Sep 13, 2018 at 6:43pm (UTC)
Duration: 5.49s, Total samples = 0
如果有帮助,我正在go version go1.11 linux/amd64
运行Ubuntu 16.04.5 LTS
. 不确定这是否重要,但我正在尝试检查 DigitalOcean 液滴上的 pprof 输出。
有什么我做错了吗?谢谢!