Re: [XPOST] [C] Access speed: pointers Vs array
From: Il Prof (chiedisulng_at_chiedisulng.org)
Date: Thu, 05 Aug 2004 18:03:03 +0200
Eric Sosman <Eric.Sosman@sun.com> wrote:
>The answer isn't useful to
>guide your programming technique, because it will be
>different on different systems -- it will even be
>different on the same system with the same compiler
>in different circumstances.
My objective was only know what string access method is faster in my
platform because i'm developing a personal tool that elaborates millions
> Second (pedantic):
Ok, i will remember! :)
>strcopy3() is just plain stupid,
>especially when the author claims to be interested in
There is an error...now i know.
>strcopy4() and strcopy5() have bugs,
Can you help my in find them? Thanks.
>clock() would be a better choice here, although
>it, too, has its problems.
I will use it next time. However I run the code 50 times and I
calculated the average time.
> Fifth: Your compiler should have complained about the
>long string literal with embedded newlines.
I have used gcc...
> Sixth: If you learn what function pointers are and how
>to use them, you can make the "timing harness" code much
>shorter and less repetitive than it now is.
I have explained that was a very simple and "brutal" code. But you are
> You need to run
>the test again and with larger repetition counts to
>determine whether the timing difference is real or is
I run the code 50 times and I calculated the average time.
Thanks for all eight points.
-- Il Prof.