
Optimisation In C and Algorithm Develpment
I think it may be apt to quote Michael Jackson (not the singer) regarding
optimization. He says,
Novices : don't do it.
Experts : don't do it, yet.
Since it is commonly agreed that a program is read many more times than it is
written, I think it is worthwhile making it more readable and fool-proof than to
despair about its efficiency.
Once a program is written, there are tools (profilers) that enable you to
determine the most exercised parts of a program. This lets you focus on sections
of code that may be improved. Once you have learnt how to improve a section, you
must still keep the earlier version because performance improvements often lead
to a loss of readability.
I think there is a book called, "Writing efficient programs in C" by Bentley
(?). You may want to read it. Also, take a look at "Programming Pearls". You may
also find Michael Jackson's book on program design for insights regarding
optimization and efficiency
Quote:
> Hi there,
> I am interested in Optimisation techniques for C language and am after
> literature or
> Web Sites, I am an applications programmer working on financial db systems,
> but I understand that Optimisation should not really be playing a major role
> in my development process, but the following are some techniques that i may
> apply, contact me if this also interests you or i have missed something.
> A) Use I nteger and long data types wherever possible for math
> computations
> B) Avoid Real data types
> C) Keep Struct size <= Cache Size
> D) Inline functions
> E) Loop Unrolling
> F) Jamming
> I am also interested in how developers first conduct problem solving - when
> they are formulating a solution to a problem, I cannot tell how fast a
> module is until i see it run, is this the same for you or different.
> I normally code the first solution that pops into my mind - then if it is
> slow once it works then I just code it, is this the same for you, is it
> possible that some of you can tell while the solution is being created in
> our minds that it will be inefficient the algo - or do we all need to test
> it thoroughly by running a working prog ?
> For applications programmers is Structure more important then speed
> efficiency - and should we really worry about speed when hardware speeds are
> doubling so quickly - what do you think ??
> Thanks