[Bug gprof/2776] Strange profiling results

2020-01-30 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=2776

Alan Modra  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |INVALID

--- Comment #3 from Alan Modra  ---
Profiling is complicated.  Very likely the time spent in gettimeofday is not
being counted.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprof/2776] Strange profiling results

2006-06-22 Thread nickc at redhat dot com

--- 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   secondscalls  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.


___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils