(转)用GNU Profiler来提高代码运行速度

适用于C, C++, Pascal, Fortran 77

原文链接:http://www.ibm.com/developerworks/cn/linux/l-gnuprof.html

 

自己的示例:

chenqi@chenqi-laptop ~/MyPro/Algorithms/sort $ gcc -o quicksort2 -std=gnu99 -O2 -pg optimized_quicksort.c cfunc.c
chenqi@chenqi-laptop ~/MyPro/Algorithms/sort $ ./quicksort2 1000000
start sorting ...
sorting finished!
====================================
Randomized Quicksort               
Sorting 1000000 elements
Time: 0s      298978us
The result is right !
====================================
chenqi@chenqi-laptop ~/MyPro/Algorithms/sort $ ls *.out
gmon.out
chenqi@chenqi-laptop ~/MyPro/Algorithms/sort $ gprof quicksort2 gmon.out -p
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total          
 time   seconds   seconds    calls  ms/call  ms/call  name   
 95.83      0.23     0.23   666354     0.00     0.00  partition
  4.17      0.24     0.01        1    10.00   240.00  quicksort
  0.00      0.24     0.00        1     0.00     0.00  malloc_c

转载于:https://my.oschina.net/u/158589/blog/61244

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值