PDA

View Full Version : gprof tool



anon10038
29-05-2012, 04:35 AM
Dear Sir,

Please tell me the command of using gprof tool and how to use it?

thanks,

anup
29-05-2012, 06:08 AM
Anon10038,

The command for gprof is gprof itself. However, you have to compile your programs with -pg option.

Thanks,

Anup

anon10038
30-05-2012, 05:36 AM
Sir,

Is the command "prof" is same as that of "gprof" which was used in PRGC?

thanks,

anup
30-05-2012, 07:02 AM
Anon10038,

prof is the old UNIX command, gprof is the prof tool from GNU suite. Functionally gprof will have much more than prof, though on GNU/Linux system, prof may be symlinked to gprof.

Thanks,

Anup

anon10298
18-07-2012, 04:25 PM
Sir,

I wrote a program which has 2 functions f1 and f2 and each executing a loop. I compiled the program with -pg option and then used gprof to see a.out. I found that in the name column i had dummy_frame as the function name which was not any function i had used. It even did not show my functions. May i know the reason for this?

Thanks

anup
18-07-2012, 04:28 PM
Anon10298,

The reason why you are not seeing anything in output of gprof is that your program may have run for a very short while. Due to this, no samples could be collected, which can in turn be reported in gprof.

I suggest, that you create a function and in that function do big loops (i.e. loop with large bound). Now compile your code with -O0 -pg. The -O0 is needed, as otherwise compiler will optimize away this loop thinking that it is not doing anything useful. Run the program and then use gprof, you will see that function in the output of gprof.

Thanks,

Anup

anup
18-07-2012, 04:34 PM
Anon10298,

I commented out the printf's from your loop code. Doing printf's in a loop is a bad idea as these functions are very slow. Also, I re-compiled and ran your code, now you can run with gprof and see that your functions are shown.

Please do the exercises in the virtuqwork created area.

Thanks,

Anup

anon10366
26-10-2012, 08:46 AM
Hi,

I am trying to run gprof but no gmon.out file id getting created.
I am giving the command g++ -pg myapp.cpp.

anup
26-10-2012, 08:56 AM
Anon10366,

The gmon.out file will only be created once you have run your program not on compilation only. Secondly look at #6 above and make sure that you are doing what that post says.

Thanks,

Anup

anon10364
12-11-2012, 07:40 AM
Sir,
Sometime running gprof -p a.out show zero time for all the function.Sir i am attaching the snapshots , please have a look.

Thanks,
Anon10364.

anup
12-11-2012, 07:50 AM
Anon10364,

Please check #6 above, your issue is most probably due to that.

Thanks,

Anup