On Nov 22, 2004, at 1:11 AM, Michael Metcalf wrote:
> Since neither x nor y is used outside the loop, their calculation is
> potentially optimized away. For this sort of test, you need to print x
> and y
> after the loop.
Or even better, use a real application for a benchmark instead of
something artificial like this. There are many ways that tests like
this can give misleading results. I have an "old favorite" one of my
applications that I've tended to use for such purposes for a while.
Admittedly, computers have gotten fast enough that it has gotten hard
for me to time the original version by hand, so these days I override
its normal algorithm and tell it to use one that's bad enough that I
can ask for 500 iterations and it will actually do that many instead of
stopping after 4 or 5 because it has converged. :-) So it isn't
entirely realistic, but it is still the actual application program, and
the bulk of the computations are the same as with it's more usual
algorithms. I'm afraid that its biggest problem these days is that the
formatted terminal I/O at the end of each iteration is becoming a
noticeable fraction of the time, even when I set it to the least
verbose level, and that's not what I'm really interested in.
It does take a little bit longer to get a real application running than
a few-liner like the OP's test... but if it takes me unreasonably long
to get my application running on a compiler, and it requires working
around a bunch of compiler bugs, then that's an something I want to
know also. In fact, it is probably more important for me to know that
I can't get my application running with reasonable effort than to
estimate how fast it isn't running. :-(
And for initial benchmark purposes, I tend to to a "quicky" port. Most
of the system-dependent things in my code are for niceties that aren't
necessary for checking the core functionality, so I can leave them as
do-nothing stub routines (of course, the system-dependent stuff is
almost all in separate routines in a separate file).
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|