適用於C, C++, Pascal, Fortran 77html
原文連接:http://www.ibm.com/developerworks/cn/linux/l-gnuprof.htmllinux
本身的示例:dom
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
ui