我试图使用gprof来证明我们的软件,但是当我执行命令时
gprof <binary-name> gmon.out
我收到以下错误:
gprof: dimension unit changed between histogram records
gprof: from 'seconds'
gprof: to ''
我假设我的二进制文件正在生成gmon.out,因此编译器必须在编译期间得到-pg开关。
我究竟做错了什么?
AmeyaVS的评论已经提到了答案:
# compile and link with -pg
gcc -pg file.c -o file
# run program to generate the gmon.out file
./file
# run gprof on your executable with matching gmon.out
gprof file gmon.out
尽量不要在守护进程或父子进程模式下运行应用程序。