在google-perftools包中有一个pprof实用程序。它是实用程序转换配置文件从google-perftools cpuprofiler和heapprofiler到美丽的图像:如https://github.com/gperftools/gperftools/tree/master/doc/pprof-test-big.gif和https://github.com/gperftools/gperftools/tree/master/doc/heap-example1.png
pprof输入文件的格式在这里描述cpu配置文件:https://github.com/gperftools/gperftools/tree/master/doc/cpuprofile-fileformat.html
但是heap profile
输入文件的格式在svn.
什么是"heapprofiling"格式,我如何从我的代码生成这样的文件?我已经可以生成cpuprofiler格式,所以我感兴趣的是两种格式之间的区别。
似乎格式不是二进制的cpu分析器,但文本:
第一行:
heap profile: 1: 2 [ 3: 4] @ heapprofile
正则表达式(不完整)
(d+): (d+) [(d+): (d+)] @ ([^/]*)(/(d+))?)?
,
- 1,2是"使用状态";第一个数字是分配数,第二个是字节数
- 3,4是"总分配状态";第一个和第二个含义相同
- heapprofile的类型是
然后配置文件本身在许多行后面:
1: 2 [ 3: 4] @ 0x00001 0x00002 0x00003
,其中"1:2"one_answers"3:4"的含义与第一行相同;但只与给定的callsite错位;0x00001 0x00002为被叫站点的callstack
然后空行和"MAPPED_LIBRARIES:"。从下一行开始,类似于/proc/pid/maps的复制。