1. poor man's profiler
(1) 通过统计call stack的情况, 来判断程序的bottleneck, 方便高效, 并有一般profile所不能统计的信息. 文章 What can I use to profile C++ code in Linux? 极度推荐, 并给出了解释.
(2) 文章 poor man's profiler 给出了具体的shell程序来统计stacks内容, 更加方便.
2. gprof
(1) linux下比较常用和老的profiling工具, linux 自带, 文章 linux环境下 C++性能测试工具 gprof 和gprof2dot 给出了使用方法, 并提到了多线程情况性能分析的解决 HOWTO: using gprof with multithreaded applications
.
(2) 但由于其必须重新编译程序, 而且存在比较严重的profiling overhead情况(为了评价程序, profiler工具会添加一些代码来跟踪统计信息, 这样就会导致跟程序本身的性能情况有所出路)
3. perf
(1) Linux下目前比较好的profier工具, 相比oprofile具有容易使用等优势, 具体的比较和分析见文章 perf: the good, the bad, the ugly
(2) ubuntu下安装 sudo apt-get install linux-tools
4. oprofile
5. perf使用
(1)若要显示调用关系图perf record要加上-g, 且本人系统后面还要加 fp