A study in code optimization in C

John Hascall hascall at cs.iastate.edu
Tue Jul 31 00:13:38 AEST 1990


rh at smds.UUCP (Richard Harter) writes:
}mcdonald at aries.scs.uiuc.edu (Doug McDonald) writes:
}> 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]

}Ouch.  I should have phrased that more carefully.  Yes, the gentleman
}is quite right.  As to be expected, a hardware bulk move is always
}going to beat code that uses item by item move instructions.

}In defense I have to point out that the quoted remark is accurate;
}timings were made on 680x0 boxes, vaxes (!), and some risc boxes,
				   ~~~~~
 Hmmm, sorry, but here's a little more rain on your parade:

 VAXstation 3200 (admittedly, not the most modern VAX), 1000 20KB copies:

		memcpy: 3.18       your macro: 15.43

John Hascall  /  john at iastate.edu  /  hascall at atanasoff.cs.iastate.edu



More information about the Comp.lang.c mailing list