lkml.org 
[lkml]   [1998]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: faster strcpy()
    From
    Date
    "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

    \
     
     \ /
      Last update: 2005-03-22 13:42    [W:2.580 / U:0.136 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site