性能评测工具 :gprof 的使用

来源:互联网 发布:linux权限不够怎么办 编辑:程序博客网 时间:2024/05/18 03:37

由于环境是WIN, 就下了MINGW

设置好环境变量后,直接编译

gcc main.cpp -pg -lstdc++

得到a.exe gprof -b a.exe gmon.out >report.txt 

Gprof 产生的信息解释:

  %time

Cumulative

seconds

Self 

Seconds

Calls

Self

TS/call

Total

TS/call

name

该函数消耗时间占程序所有时间百分比

程序的累积执行时间

(只是包括gprof能够监控到的函数)

该函数本身执行时间

所有被调用次数的合共时间

函数被调用次数

函数平均执行时间

(不包括被调用时间)

函数的单次执行时间

函数平均执行时间

(包括被调用时间)

函数的单次执行时间

函数名



测试程序:

Flat profile:


Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total    time   seconds   seconds    calls   s/call   s/call  name    
 24.60      5.55     5.55    59950     0.00     0.00  Cut(std::vec ....
 19.44      9.94     4.38 566119378     0.00     0.00  Intersection(Interval, Interval)
 11.30     12.48     2.55 566147918     0.00     0.00  Interval::Interval(int, int)

可以看出 cut函数 占用了 24% 是 关键函数,如果要优化程序,可以从此处入手

0 0
原创粉丝点击