www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/05/20:25:18

Mime-Version: 1.0
To: Bernard Schmitz <bernard AT hunterlink DOT net DOT au>, djgpp AT delorie DOT com
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: problem with profiling with optimization...
Date: Tue, 5 May 1998 17:19:48 -0700
Message-ID: <19980506001904.AAG3698@ppp124.cartsys.com>

At 03:31  5/5/1998 +1000, Bernard Schmitz wrote:
>Is profiling with optimization liable to break code?
>
>I've always profiled using the flags -g -pg -m486 -O3 and
>never had a problem until now.
>
>My code was working fine compiled with debug info.  I decided to
>profile it and found that it produced different results!  At first
>I thought it was a bug that had only become apparent because of 
>profiling/optimizing.  I compiled with optimization using -O3 -m486
>-finline-functions -fomit-frame-pointer and the code worked perfectly!
>
>Compiling the same code with profiling but no optimization works.
>That will do, but I was surprised that the profiling/optimization 
>affected just a small section of code, just one function in fact!
>
>So basically is it a good idea to profile using optimization??
>Can you turn off profiling for one function?

Yes, in general you should compile with optimizations when profiling.
Otherwise, you will end up seeing hot spots in places that the compiler can
actually optimize better. No, you cannot selectively disable profiling
within a single file, unless you hack the GCC source to allow it (not
recommended).

First of all, there is a bug in the profiling code, but AFAIK it shows up
only as crashes, or perhaps text on a mono screen. See FAQ section 16.2 for
what to do about it.

Exactly what is this code that works differently when profiling? If it has
anything to do with the time, that could be involved. Profiled programs run
slower due to the profiling overhead (but the results should still be
accurate). If you can reproduce the problem with a small, but complete,
piece of code, please post it.

Nate Eldredge
nate AT cartsys DOT com



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019