Re: faster strcpy()

Michael O'Reilly (michael@metal.iinet.net.au)
27 Apr 1998 09:29:18 +0800


"Richard B. Johnson" <root@chaos.analogic.com> writes:
> > > Simple memcpy, guaranteed to work (not the most efficient)
> > >
> > > mov esi,offset source ; 4 clocks
> > > mov edi,offset destination ; 4 clocks
> > > mov ecx,dword ptr [count] ; 6 clocks
> > > shr ecx,1 ; 2 clocks
> > > rep movsw ; 6 * number of words
> > > adc ecx,ecx ; 2 clocks
> > > rep movsb ; 6 * number of bytes
> >
> >
> > This is ~ 1.5 * num_of_bytes + const
> >
>
> Bull this is 6 times the number of words as stated, not 1.5 times
> anything.

And each word is 4 bytes, so you're taking 6 clocks per word + const,
or 1.5 clocks per byte + const.

> > So this strlen + move is ~11.5 * num_of_bytes whereas the strcopy is
> > ~16 * num_of_bytes
>
> Wrong.

Have you actually tried benchmarking this? It's kinda hard to argue
with the facts.

Michael.

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