profiling of C++ code
I am trying to find a good profiling tool for my C++ code, I tried gprof, but it does not do what I want. Maybe I didn't use gprof properly or there may be other profiling tool (such as "shark") I can download. I tried this code:
struct A {
int pro funcone() { return 2; }
int pro functwo() { return 3; }
};
int main ( ) {
A a; int j;
for(unsigned int i=0;i<1000;++i) {
j+= a.pro funcone();
j+= a.pro functwo();
}
}
g++ -O0 -fno-default-inline -pg gprof.C
./a.out
gprof a.out > pro_results.dat
tail -8 pro_results.dat
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.0 0.00 0.00 2000 0.00 0.00 past end of text [1]
0.0 0.00 0.00 1 0.00 0.00 _main [33]
Index by function name
[33] _main [1] past end of text
As you can see, there are a total of 2000 function calls, but gprof does not differentiate between pro funcone and pro functwo, it does not even list the function names.
I saw some posting on Nov 2005 saying Shark is a better profiling tool. Where can I download it? I tried google and as well as searching apple.com downloads without sucess. Will appreciate if someone can give me some pointers where to get Shark or solve my gprof problem. Thank you.
Sincerely,
Hwee Kuan
iMac mini, Mac OS X (10.4.3)