gprof + kprof + gprof2dot (性能 与 函数调用图)-

http://www.cnblogs.com/rocketfan/archive/2009/11/15/1603465.html

http://blog.csdn.net/stanjiang2010/article/details/5655143

http://blog.csdn.net/stanjiang2010/article/details/5655143

 

三种方案:

1.程序编绎加 -PG:
g++ -pg -g -o test test.cc

    ./test   //运行后生成gmon.out

     gprof ./test > prof.log

 

 2. KProf 是gprof 版本////注意已经按照前面的用gprof生成 gmont.out 了

      kprof -f ./test

 

 3. gprof2dot.py 与 xdot:生成图像清晰,相对于KProf

      gprof ./test | gprof2dot.py | xdot



 

 

gprof:系统自带
https://sourceware.org/binutils/docs/gprof/
https://sourceware.org/binutils/

The GNU Binutils are a collection of binary tools. The main ones are:


  • ld - the GNU linker.
  • as - the GNU assembler.

But they also include:


  • addr2line - Converts addresses into filenames and line numbers.
  • ar - A utility for creating, modifying and extracting from archives.
  • c++filt - Filter to demangle encoded C++ symbols.
  • dlltool - Creates files for building and using DLLs.
  • gold - A new, faster, ELF only linker, still in beta test.
  • gprof - Displays profiling information.
  • nlmconv - Converts object code into an NLM.
  • nm - Lists symbols from object files.
  • objcopy - Copies and translates object files.
  • objdump - Displays information from object files.
  • ranlib - Generates an index to the contents of an archive.
  • readelf - Displays information from any ELF format object file.
  • size - Lists the section sizes of an object or archive file.
  • strings - Lists printable strings from files.
  • strip - Discards symbols.
  • windmc - A Windows compatible message compiler.
  • windres - A compiler for Windows resource files.
 

 

kprof

http://kprof.sourceforge.net/


% tar xvfz kprof-1.4.1.tar.gz
% cd kprof-1.4.1
% ./configure --prefix=(where KDE is installed, for example /opt/kde3)
% make
% su
enter your root password
# make install

KProf is a visual tool for developers, which displays the execution profiling output generated by code profilers. 
The output of profilers being usually difficult to read (beyond the flat profile information),
KProf presents the information in list- or tree-views that make the information very easy to understand. KProf provides access to the following features: Flat profile view displays all function / methods and their profiling information. Hierarchical profile view displays a tree for each function / method with the other functions / methods it calls as subelements. Object profile view, for C++ developers, groups the methods in a tree view by object name. Graph view is a graphical representation of the call-tree, requires GraphViz to work. Method view is a more detailed look at an individual method - cross referenced. Recursive functions carry a special icon to clearly show that they are recursive. Right-clicking a function or method displays a pop-up with the list of callers and called functions.
You can directly go to one of these functions by selecting it in the pop-up menu. The flat profile view provides an additional filter edit box to filter the display and show only the functions or methods
containing the text that you enter. Function parameters hiding
if the function name is unique (i.e. no different signatures) C++ template abbreviation (template parameters can be hidden) Automatic generation of call-graph data for GraphViz and VCG, two popular graph image generators. Diff mode support to compare two profile results.

 

gprof2dot     (.txt----->.dot)

https://github.com/jrfonseca

 

xdot.py是 一个图形可交互查看器,采用Graphviz的 dot 语言开发      (DOT文件------>图像生成)

https://github.com/jrfonseca/xdot.py

xdot.py 0.5 发布,图形互动查看器

image

posted @ 2016-06-08 16:51  zengkefu  阅读(2154)  评论(0编辑  收藏  举报