Mail Archives: djgpp/1997/04/08/01:18:40
In article <3348B1FF DOT 167E AT gig DOT nl> bram AT gig DOT nl "Bram Stolk" writes:
> > He is doing 50,000 calculations in a 'for' loop, not pausing.
> > I'm sure this should be in the FAQ, as it's one of the
> > important aspects that everyone needs.
>
> When benchmarking:
>
> Make sure, that the result of the calculations is used
> afterwards (in a printf or so).
>
> If you don't, a smart compiler will optimize it, and remove
> the calculations entirely.
>
> This is what happened to me, after writing a very naive
> benchmark :-)
> The smart compiler was Sun's cc.
I was under the impression (can't remember where from) that gcc recognises
such loops as being (somewhat innaccurate) timing loops, and so doesn't
optimise them away.
BTW, using printf will introduce I/O into your benchmark, and that will
become the dominant factor. Do something more useful like fill a very large
array.
--
:sb)
- Raw text -