1

我正在使用gperftools来分析我的 C 代码。结果我无法使用pprof应用程序分析配置文件。

$ gcc -g prog.c -o prog -lprofiler
$ export CPUPROFILE=info.prof
$ ./prog 

 Inside main()

 Inside func1 

 Inside new_func1()

 Inside func2 
PROFILE: interrupts/evictions/bytes = 1133/0/300
$ ls
info.prof  prog  prog.c
$ ls -lah info.prof 
-rw-rw-r-- 1 mm mm 2.6K Jun  6 09:36 info.prof
$ pprof info.prof prog
Reading Profile files in profile.*
Error: Could not open profile.0.0.0: No such file or directory
profile.ftab: No such file or directory
$ 

我错了什么?文件是什么profile.ftab

4

3 回答 3

9

您没有使用正确的“pprof”工具。特别是,您使用的是http://www.cs.uoregon.edu/research/tau/docs/newguide/bk03ch01s08.html(完全不相关),而您需要这里的一个:https://code。 google.com/p/gperftools/ 我遇到了同样的问题,并通过下载 gperftools 的源代码、构建它并使用 ./src/pprof 解决了这个问题

于 2014-11-14T05:02:57.970 回答
7

我刚刚遇到这个问题,我认为值得一提的是如何在最新版本的 Ubuntu(特别是 18.04)中处理这个问题。

当尝试运行该pprof命令时,系统会建议安装该tau软件包:

Command 'pprof' not found, but can be installed with:

sudo apt install tau

但是不要安装该软件包,因为正如大卫卡尼在他​​的回答中指出的那样,它完全不相关。而是安装google-perftools包,但请注意其中的可执行文件被调用google-pprof,而不仅仅是pprof.

于 2018-12-27T16:23:06.210 回答
0

您安装了错误的 pprof。

如果你已经安装了 golang。您可以使用 go 安装 pprof。做就是了,

去获取 github.com/google/pprof

graphviz如果您想使用生成 PDF,也请安装

sudo apt-get install graphviz
于 2021-12-02T06:55:06.417 回答