Mail Archives: djgpp/1997/05/19/21:18:35
jon wrote:
>
> I'm interested in understanding what can be done to speed up straight
> C code. In the specific thing I am writing, I've already done the
> obvious things, like switched most calcs from FP to integer, using bit
> shifting wherever possible for multiplying and dividing, etc. But is
> there a complied source of information on just
> what-is-faster-than-what? Like, does running a "for" loop by
> decrementing rather than incrementing actually save a cycle? or does a
> "case" command actually beat a series of "if"s? Do global variable
> speed things up? I figure there must be something out there that has
> the low-down on just this sort of nitty-gritty info.
>
> DJGPP is my compiler of choice, if that makes a difference.
Learn assembly. While actually writing a lot of asm is of questionable value,
it does help you understand how to write optimized code. Somethings like bit
shifting for division, if they actually buy anything you need a new compiler.
In "general" just reduce the amount of work that needs to be done. Either with
smarter algorithms or some type of caching.
--
David Matiskella
davidm AT netscape DOT com
- Raw text -