bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gprof/2776] Strange profiling results


From: nickc at redhat dot com
Subject: [Bug gprof/2776] Strange profiling results
Date: 22 Jun 2006 14:03:18 -0000

------- Additional Comments From nickc at redhat dot com  2006-06-22 14:03 
-------
Subject: Re:  New: Strange profiling results

Hi Dmitry,

> void f (int n) 
> {
>       rdtscll (t);

> void g (int n) 
> {
>       gettimeofday (&tv, 0);

> int main (int argc, char *argv[])
> { 
>   int n;
> 
>   for (n = 0; n < 200; n++) {
>     if (n % 2)
>       f (n);
>     else
>       g (n);

> My typical results are:
> 
> $ gcc -O2 -g -pg -o test test.c                        
> $ gprof test | head -n 10                            
> Flat profile:
> 
> Each sample counts as 0.01 seconds.
>   %   cumulative   self              self     total           
>  time   seconds   seconds    calls  ms/call  ms/call  name    
>  95.85      0.40     0.40      100     4.03     4.03  f
>   4.79      0.42     0.02      100     0.20     0.20  g

Have you checked the assembler output of the compiler ?  Perhaps it is 
being clever.  Maybe it knows that all but the calls to gettimeofday are 
redundant ?

What about main(), is any time spent in that function ?

Also it appears that the two percentages above add up to more than 100%.

The most likely though is that bad profiling data is being generated. 
ie it is not gprof's fault but either gcc's (for not inserting the calls 
to the profiling hooks correctly) or else the run time C library's (for 
not implementing the profiling hooks correctly).  Check you version of 
gcc.  If it is an old one, then try updating it.  If it is a new one, 
then try using an older one and see if the problem goes away.

Cheers
   Nick



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=2776

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]