[Ilugc] Profiling a C program.

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Thu Mar 13 07:51:56 2008

On 00:00:40 Mar 13, Logu wrote:

I am trying to profile a simple C program, but I am not getting correct 
values under the  "cumulative seconds"  and "self seconds" column for the 
functions. I always get them as 0.00.

I compiled and linked the program with -pg option. But when I run the gprof 
I only get this output

 %   cumulative   self         self     total
time   seconds   seconds    calls   Ts/call  Ts/call  name
 0.00      0.00     0.00        5        0.00     0.00    pmesg

Could someone point me what I am missing here. I need to find the time 
spent on each function calls.


I barely remember using gprof.

I have found the simple shell command time(1) to be far more easier to
use and helpful.

I remember gprof reporting huge amounts of data. How did you get just
one line?

There are plenty of profiling/monitoring tools in linux.

Why don't you try the other ones?

lsof(1), fstat(1) and so on.

I think you can simply

$ time ./a.out

for your immediate need.

As to why gprof results weird results, the answer might be far deeper
than what meets the eye.

As someone suggested you can try a few iterations.

-Girish

Other related posts: