TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: HERMAN SCHONFELD
from: CHRIS DOWNS
date: 1997-04-06 19:30:00
subject: Re: Video

 HS> Bit shifting will ALWAYS be faster than multiplying.
 
 MW>According to a book I am reading right now. Bit shifting is faster by a
 MW>factor of around 3 times. You just have to be careful if you shift too
 MW>far you may lose significant bits. :-(
 HS> My point exactly, you should forward this message to the Chris Downs.
No.  The point was made that substituting a multiply with two bit shifts
and two adds makes for a performance plus.
 
The problem is that I've bench marked it.  Counting cycles
is not a satisfactory substitute.  The add/bit shift has more code.  Did
you count the cycles needed to load the code into the instruction
pipeline (for example)???
It's _so_simple_ to get the exact answer by running such a simple test.
I *know* that substituting an bit shifts/adds for an integer multiply
on a 386 is a performance loser.  (Because I tested it) I also know that
substituting a bit shift for a multiply by a constant power of two is a
waste of effort for every compiler I use.  (Again because I tested it.)
Since I don't like to play lose/lose scenarios, I'll pass on the above
advice.  (But I certainly can be swayed by reliable evidence.  How
about bench marking your performace "improvements" and supplying
us with the results??  It would be quite educational!)
---
 þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.