delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/13/16:03:20

From: gerryq AT indigo DOT ie (Gerry Quinn)
Newsgroups: comp.os.msdos.djgpp,rec.games.programmer
Subject: Re: Any tips on optimizing C code?
Date: Tue, 13 May 97 19:42:10 GMT
Organization: Indigo
Lines: 32
Message-ID: <5lacqu$o3p$2@news.indigo.ie>
References: <33775c59 DOT 19219875 AT news DOT cis DOT yale DOT edu>
NNTP-Posting-Host: ts01-03.drogheda.indigo.ie
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <33775c59 DOT 19219875 AT news DOT cis DOT yale DOT edu>, quacci AT vera DOT com (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.
>

In a sense, haven't you answered your own question?  You know what speed the 
thing you are writing runs at, and whether your changes made a difference.

If you are stretching a modern machine, you must be doing something very 
specific and time-consuming most of the time, so profiling is the answer.

I used to have a big prejudice against FP operations, but I must say, I have 
recently been amazed at the ability of my Pentium to eat them.  But it all 
depends whether you are calculating an array index etc., because if FP must be 
converted to int, it's best to be in int from the start.

- Gerry

==================================================================
 Mailto: gerryq AT indigo DOT ie  (Gerry Quinn)
 Original puzzlers (Windows or Amiga)-> http://indigo.ie/~gerryq
==================================================================

- Raw text -


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