Re: faster strcpy()

Richard B. Johnson (root@chaos.analogic.com)
Fri, 24 Apr 1998 08:22:01 -0400 (EDT)


On Fri, 24 Apr 1998 umforema@cc.UManitoba.CA wrote:

> I'm not sure if this is a libc thing or a kernel thing, but I noticed
> that strcpy is in the kernel include files, so here goes...
> I changed the definition of strcpy in /usr/include/string.h to
>
> #define strcpy(a,b) (char *)memcpy(a,b,strlen(b))
>
> It slightly more than doubles the speed of strcpy on my pentium machine.
>

Could you please describe how you measured its speed? You actually
more than doubled the number of CPU instructions that need to be
executed to perform this function.

I think that the only explaination is that during your comparison
testing, one of the strings and/or instruction sequences becomes
cache-aligned while the other doesn't. The unaligned procedure
should be slower.

Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.92 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu