What looks efficient may not be

Ray Swartz ray at saturn.ucsc.edu
Sun May 28 01:24:07 AEST 1989


I recently was surprised to discover that 

     while (i < 500000)
	 ++i;


ran much faster than

     while (i < 500000))
	  i++;


The test ran on a 68020 based machine.  This test was run without using
the optimizer.  Here is yet another example that shows that optimizing
from a higher level language may backfire.
Incidentally, I realize the loops don't do anything, I was testing some 
alternatives ways of doing timing loops.



More information about the Comp.lang.c mailing list