delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/19/21:18:35

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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019