Path: utzoo!attcan!uunet!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!aries!mcdonald From: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Newsgroups: comp.lang.c Subject: Re: A study in code optimization in C Keywords: memcopy Message-ID: <1990Jul26.144134.16053@ux1.cso.uiuc.edu> Date: 26 Jul 90 14:41:34 GMT References: <133@smds.UUCP> Sender: usenet@ux1.cso.uiuc.edu (News) Reply-To: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Organization: School of Chemical Sciences, Univ. of Illinois at Urbana-Champaign Lines: 50 In article <133@smds.UUCP> rh@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!. Time on my computer, in seconds, for 1000 copies of a 20 kilobyte array: His code library memcpy Compiler 1: (chars) 12.6 2.7 (ints) 6.9 2.7 Compiler 2: (chars) 23.6 1.3 (ints) 6.9 1.3 Results were the same for library memmove, aligned or unaligned. Sure looks like his code loses. As I would expect, of course: The library can do the whole 20 kilobytes in one instruction, assuming aligned operands. Unaligned, it takes a few more. When people post things like this, perhaps they could test them, at least on the most common computers. My computer is an example of the next to the top of the line of the most common processor line(*) the world has ever known. At least, folks, test on one of these!! Doug McDonald (*) It is a 20 MHz Dell 310, 80386. The compilers were Microsoft C and Microway NDPC.