PDA

View Full Version : How to profile C program?



biso
December 16th, 2007, 08:58 PM
Dears,

I developed a C program and I want to measure CPU, memory and IO access of the program? any tool to do that??


Thanks in advance
BISO

slavik
December 16th, 2007, 09:04 PM
look into valgrind

biso
December 16th, 2007, 09:15 PM
Thanks for the tool.
Is there any built-in tools in unix?

slavik
December 17th, 2007, 12:07 AM
there is time, but it will only tell you the amount of time the process spent running in user mode, the time it spent for doing system calls and the total time it ran. (consider it as a general overview of which your app does most).

Wybiral
December 17th, 2007, 12:12 AM
"gprof" is another option.

Majorix
December 17th, 2007, 12:42 AM
Is there any built-in tools in unix?

I haven't come across any if there is, but it would be great to have one. It could even be built into gcc, which when called with an option like --profile tells you the profile info. Just dreaming :p

jpkotta
December 17th, 2007, 05:48 AM
Take a look at OProfile too. It profiles the entire system (kernel too) with a kernel module. You can of course narrow things down to a specific program.

biso
December 17th, 2007, 09:48 AM
"gprof" is another option.

Thanks a lot, gprof is what i need :)

kuscsik
January 29th, 2008, 05:41 PM
Here is a simple example of using gprof

http://kuscsik.blogspot.com/2007/08/how-to-benchmark-c-code-using-gcc.html

I hope you will find it useful.