On Mon, 23 Jun 2003, Andrew Pinski wrote:
Here is the result on my laptop (a PowerBook 800MHz G4 running Mac OS
X
10.2.6, Darwin 6.6) I used the PPC TimeBase register as the timer,
also
I made the buffer size 102400 plus one for the zero:
sprintf 5618
strcpy 21422
strcpy+strlen(buf2) 25291
strlen(strcpy(buf1, buf2)) 25456
As you can see that the sprintf wins over just strcpy (without a even
strlen), the strlen adds about the same time as how long sprintf
takes.
Can someone else also confirm these figures? Is the call to strcpy
getting inlined badly? What are the times for an equivalent memcpy?
I'm just very confused by these numbers. Has this "bug" been filed
with
the Apple folks, or should I consider an optimization that converts
calls
to strcpy into calls to sprintf on some platforms? Hopefully, its just
a case where we inline a strcpy where we should be calling the larger
but
more efficient system library routine.