bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] two small patches


From: Giuseppe Scrivano
Subject: Re: [Bug-tar] two small patches
Date: Thu, 17 Jun 2010 01:28:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi Paul,

Paul Eggert <address@hidden> writes:

> Thanks for the missing prototype, but I don't see why replacing
> tar_copy_str with strncpy is a win.  The former is much more
> efficient than the latter when the string length is much smaller
> than the LEN argument.  This is because the latter always stores
> LEN bytes, whereas the former stores at most (string length + 1)
> bytes.
>
> Perhaps a comment should be added to tar_copy_str to explain this.

Thanks for the review.  I didn't think about the impact on the
performance.

Just for the record, I have done some tests, copying 10000000 times a
string with different lengths, using always the same buffer size (1024
bytes).

`strncpy' comes from the Debian libc6-i686 package (2.11.1-3).

`duff_str_copy' is the Duff's device version.


Compiled with gcc (Debian 4.4.4-1) 4.4.4 using -O2.


Cheers,
Giuseppe



strncpy: strlen (src)=1024 N=1024 time=9570 ms
strncpy: strlen (src)=512 N=1024 time=8803 ms
strncpy: strlen (src)=256 N=1024 time=8390 ms
strncpy: strlen (src)=128 N=1024 time=7955 ms
strncpy: strlen (src)=64 N=1024 time=7782 ms
strncpy: strlen (src)=32 N=1024 time=7799 ms
strncpy: strlen (src)=16 N=1024 time=7672 ms
strncpy: strlen (src)=8 N=1024 time=7590 ms
strncpy: strlen (src)=4 N=1024 time=7535 ms
strncpy: strlen (src)=2 N=1024 time=7650 ms

tar_copy_str: strlen (src)=1024 N=1024 time=11022 ms
tar_copy_str: strlen (src)=512 N=1024 time=5549 ms
tar_copy_str: strlen (src)=256 N=1024 time=2809 ms
tar_copy_str: strlen (src)=128 N=1024 time=1433 ms
tar_copy_str: strlen (src)=64 N=1024 time=747 ms
tar_copy_str: strlen (src)=32 N=1024 time=278 ms
tar_copy_str: strlen (src)=16 N=1024 time=142 ms
tar_copy_str: strlen (src)=8 N=1024 time=87 ms
tar_copy_str: strlen (src)=4 N=1024 time=50 ms
tar_copy_str: strlen (src)=2 N=1024 time=30 ms

duff_str_copy: strlen (src)=1024 N=1024 time=8216 ms
duff_str_copy: strlen (src)=512 N=1024 time=4195 ms
duff_str_copy: strlen (src)=256 N=1024 time=2085 ms
duff_str_copy: strlen (src)=128 N=1024 time=1060 ms
duff_str_copy: strlen (src)=64 N=1024 time=552 ms
duff_str_copy: strlen (src)=32 N=1024 time=303 ms
duff_str_copy: strlen (src)=16 N=1024 time=174 ms
duff_str_copy: strlen (src)=8 N=1024 time=109 ms
duff_str_copy: strlen (src)=4 N=1024 time=77 ms
duff_str_copy: strlen (src)=2 N=1024 time=61 ms



reply via email to

[Prev in Thread] Current Thread [Next in Thread]