Re: [XPOST] [C] Access speed: pointers Vs array

From: Il Prof (chiedisulng_at_chiedisulng.org)
Date: 08/05/04


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
of strings.

> Second (pedantic):

Ok, i will remember! :)

>strcopy3() is just plain stupid,
>especially when the author claims to be interested in
>micro-optimization.

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
right.

> You need to run
>the test again and with larger repetition counts to
>determine whether the timing difference is real or is
>merely "jitter."

I run the code 50 times and I calculated the average time.

Thanks for all eight points.

-- 
Il Prof.


Relevant Pages

  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... Big-O notation isn't mathematics per se, it's computer science notation ... "length of the string". ... outrun something compiled and optimized by a good C compiler. ... > either general computing culture or culture outside computing. ...
    (comp.programming)
  • Re: [EGN] Hoisting Loop Invariants (Was: Re: [EGN] Numerical Accuracy)
    ... compiler out there somewhere that did as you claim. ... > the programmer has this knowledge, then the programmer should not use ... >> string in a loop, regardless of the blatant inefficiency of doing so. ...
    (comp.programming)
  • Re: How to convert Infix notation to postfix notation
    ... and make all strings const save where the intent ... function whose contract is to change the string. ... the compiler "just" prevents the string ... try to do using the pointer you get. ...
    (comp.lang.c)
  • Re: PL/I string representations
    ... >> of the language, so it was interesting to me, hopefully it will be to ... I found a workable compiler for Fortran in 1971 (with a bug ... >> The specified length is the minimum, and each time a character ... >> string is assigned to E, the length is stored with it. ...
    (comp.programming)
  • Why C Is Not My Favourite Programming Language
    ... C has no string type. ... compiler take care of the rest. ... Why does any normal language ... the programmer fail. ...
    (comp.lang.c)