A study in code optimization in C

David Olix dwho at nmt.edu
Sun Jul 29 09:14:10 AEST 1990


In article <134 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:
>In article <1990Jul26.144134.16053 at ux1.cso.uiuc.edu>, mcdonald at aries.scs.uiuc.edu (Doug McDonald) writes:
>> In article <133 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:
>
>> >The macro shown below is an optimized memory to memory copy macro.
>> >It is probably faster than memcopy on your machine -- I have checked
>> >it on several machines and have always found it to be faster.
>>                                  !!!!!!
>
>> Oh My!.
>
>	[Superior timings for a 20KB move on a 386 by memmove given]
>

[Explanation for slower performance on 386 deleted]

>In defense I have to point out that the quoted remark is accurate;
>timings were made on 680x0 boxes, vaxes (!), and some risc boxes, [...]

   Just for kicks I did the following test on these machines:
   Sun 3/280 (68020) running SunOS 4.1,
   HP 9000/835 (HP Precision Architecture RISC) running HP-UX 7.0,
   and a VAX 750 running 4.3 BSD (don't laugh, it still runs!)

   Timings are in seconds based on 1000 copies of a 20K char array.
   Compile commands were:  cc -O and gcc -O -fstrength-reduce
   -finline-functions.

                Macro (copy)             Library (memcpy)
Compiler     Sun    HP    VAX           Sun    HP    VAX
   cc         7     7      52            3      1     95  <--
  gcc         8    ---     51            2     ---    96

Oddly, the macro *DOES* seem to work faster on the VAX (Gee, so I guess
all the world *is* a VAX :-) :-) :-)

>Richard Harter, Software Maintenance and Development Systems, Inc.
>Net address: jjmhome!smds!rh Phone: 508-369-7398 
>US Mail: SMDS Inc., PO Box 555, Concord MA 01742
>This sentence no verb.  This sentence short.  This signature done.

--David Olix
dwho@{nmtvax|nmtsun|minos}.nmt.edu  .sig under construction
Any connection between my views and NMIMT's is purely coincidental



More information about the Comp.lang.c mailing list