delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/19/12:04:32

From: milosek AT mhv DOT net
Newsgroups: comp.os.msdos.djgpp,rec.games.programmer
Subject: Re: Any tips on optimizing C code?
Date: Thu, 15 May 1997 00:03:07 -0400
Organization: MHVNet
Lines: 59
Message-ID: <337A8AFB.7E86@mhv.net>
References: <33775c59 DOT 19219875 AT news DOT cis DOT yale DOT edu> <01bc5f6f$c3000be0$cf1afec3 AT robert> <337865D0 DOT FB8 AT cornell DOT edu> <33793055 DOT 19327180 AT news DOT cis DOT yale DOT edu>
Reply-To: milosek AT mhv DOT net
NNTP-Posting-Host: ulster-port93.mhv.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I recently did some testing of integer multiplication vs. shifting on

a 386 16mhz, 486 32mhz and a 75mhz laptop and was doubting the results

until I read Jon's post. There wasn't the dramatic difference I was lead

to believe. I would like this thread to continue with the emphasis on

arriving at a series of tests agreeable to all involving an exchange 

of source code (different compilers)to prove the speed of functions on

all machines and cards. 



jon wrote:
> 
> On Tue, 13 May 1997 09:00:00 -0400, "A. Sinan Unur" <asu1 AT cornell DOT edu>
> wrote:
> 
> >Robert Blum wrote:
> >>
> >> jon <quacci AT vera DOT com> 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.
> >>
> >> Duh.. That must have been from a very old source of information. On
> >> the Pentium (I assume you use one), FP is even faster than integer
> >> performance.
> 
> I program on a 486 at home, and test all of it on a pentium at work.
> 
> If you mean straight multiplication and division, yes, the gap has
> been closed, more or less. But a trick like bit-shifting is still
> faster than regular division, integer or FP. And unfortunately, you
> can only do such tricks with integers.
> 
> What I have found is that I've sped up my present project enormously
> by making the key loops use integer math rather than FP- and while the
> increase is greatest on my 486, it is still very significant on the
> pentium too.
> 
> >actually, that has been so since the 486. michael abrash wrote about his
> >experience in dr dobbs some time ago. anyway, the moreal of the story is
> >"measure before you optimize".
> 
> Oh, I've measured and measured. This is why I posted this, and I'll
> ask again- has somebody else done all the measuring already? Is there
> someplace I can know that using a case is faster than an if, or are
> static ints a plus in functions that are called a lot- stuff like
> that.
> 
> I've found out all sorts of weird things- like, looking up on lookup
> table using a mutlidimensional array was *slower* than simply doing
> the math each time in one case I was working on... that was
> dissapointing.

- Raw text -


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