linux c代码 统计函数执行时间

 

加编译选项 -pg 运行后可以生成函数运行时间的统计,不过就是执行文件有点,跑起来会慢多少没测试过。前一段看汇编说过这个,但一转眼就忘了,记录在此。在 《汇编语言程序设计》这本书里。

生成的文件用来查看   gprof ./test ./gmon.out

gprof OPTIONS EXECUTABLE-FILE gmon.out BB-DATA [YET-MORE-PROFILE-DATA-FILES...] [> OUTFILE]

gprof产生的信息
%                        the percentage of the total running time of the
time                     program used by this function.
                           函数使用时间占所有时间的百分比。
cumulative          a running sum of the number of seconds accounted
seconds             for by this function and those listed above it.
                           函数和上列函数累计执行的时间。
self                    the number of seconds accounted for by this
seconds             function alone. This is the major sort for this
                          listing.
                          函数本身所执行的时间。
calls                   the number of times this function was invoked, if
                          this function is profiled, else blank.
                          函数被调用的次数
self                   the average number of milliseconds spent in this
ms/call               function per call, if this function is profiled,
                         else blank.
                          每一次调用花费在函数的时间microseconds。
total                  the average number of milliseconds spent in this
ms/call               function and its descendents per call, if this
                          function is profiled, else blank.
                          每一次调用,花费在函数及其衍生函数的平均时间microseconds。
name                 the name of the function. This is the minor sort
                          for this listing. The index shows the location of
                          the function in the gprof listing. If the index is
                          in parenthesis it shows where it would appear in
                          the gprof listing if it were to be printed.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值