Mail Archives: djgpp/1997/05/15/00:19:31
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 -