From: davidm AT netscape DOT com Newsgroups: comp.os.msdos.djgpp,rec.games.programmer Subject: Re: Any tips on optimizing C code? Date: Wed, 14 May 1997 13:44:02 -0700 Organization: Another Netscape News Server User Lines: 23 Message-ID: <337A240F.DC6D5AD6@netscape.com> References: <33775c59 DOT 19219875 AT news DOT cis DOT yale DOT edu> NNTP-Posting-Host: h-207-1-145-174.mcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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