Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Bernard Schmitz , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: problem with profiling with optimization... Date: Tue, 5 May 1998 17:19:48 -0700 Message-ID: <19980506001904.AAG3698@ppp124.cartsys.com> Precedence: bulk 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