Go pprof无法正常工作

huangapple go评论75阅读模式
英文:

Go pprof not working properly

问题

我正在尝试让pprof与Golang一起工作。

--text 似乎可以正常工作,但大多数其他选项都无法正常工作。

例如,使用 pdf 选项:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --pdf ./src /tmp/profile578584736/cpu.pprof > out.pdf
sh: 1: dot: not found
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

使用 gv 选项:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --gv ./src /tmp/profile578584736/cpu.pprof 
sh: 1: dot: not found
gv -scale 0
Can't exec "gv": No such file or directory at /usr/local/go/pkg/tool/linux_386/pprof line 719.
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

我需要在Go中进行一些更改才能使其正常工作吗?

英文:

I'm trying to get pprof working with Golang.

--text seems to work fine but most of other options does not work.

For instance with pdf:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --pdf ./src /tmp/profile578584736/cpu.pprof > out.pdf
sh: 1: dot: not found
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

With gv:

root@ubuntu:/home/user/IdeaProjects/go_projects/src# go tool pprof --gv ./src /tmp/profile578584736/cpu.pprof 
sh: 1: dot: not found
gv -scale 0
Can't exec "gv": No such file or directory at /usr/local/go/pkg/tool/linux_386/pprof line 719.
root@ubuntu:/home/user/IdeaProjects/go_projects/src# 

Is there something that I need to change in Go to get it working?

答案1

得分: 91

对于在 Mac 上使用 Homebrew 的任何人遇到这个问题:

brew install graphviz
英文:

For anyone on a Mac using homebrew that comes across this question:

brew install graphviz

答案2

得分: 64

你需要安装 dotgv。我看到你正在使用Ubuntu,只需尝试运行 apt-get install graphviz gv

英文:

You need dot and gv installed. I see you're using Ubuntu, just try apt-get install graphviz gv

答案3

得分: 1

在Windows 10上遇到了类似的错误。我通过从这里https://graphviz.org/download/安装graphviz来解决它。之后我重新启动了我的IDE,执行了pdf和png命令,一切都正常工作了。

英文:

Got a similar error on Windows 10. I fixed it by installing graphviz from here https://graphviz.org/download/. After that I restarted my IDE, issued the pdf and png commands and everything worked

答案4

得分: 0

Ubuntu的另一种选择

$ sudo apt install graphviz
英文:

An alternative option for Ubuntu

$ sudo apt install graphviz

huangapple
  • 本文由 发表于 2014年10月6日 20:51:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/26216628.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定