Optimal programming advice



Hi,

Does anyone know of any good general guidelines for making code faster? In
fact is it worth bothering at all or are the compilers so good now that
they'll do all the optimization for you?

I ask because a while ago I tried to speed up a routine I was using by
reducing the number of calculations. If I compiled the original and the
reduced version without any -O options then the new code was faster by a
factor of 2. Once I turned the -O options on however the new code was
slower so I must have been hindering the optimizer some how.

Examples I'd be interested would be how fast is checking a number versus
addition and/or multiplication. For instance if I do a complicated
calculation and then multiply it by zero, would it be best to check if the
multiplier is zero first or not bother at all?

I haven't found much of use on the Internet so it may just be a black art
but I'd like to know if anyone had any advice.

Thanks

Glyn
.



Relevant Pages

  • Re: Optimal programming advice
    ... Glyn Edwards wrote: ... > Does anyone know of any good general guidelines for making code faster? ... > fact is it worth bothering at all or are the compilers so good now that ... > they'll do all the optimization for you? ...
    (comp.lang.fortran)
  • Re: Optimal programming advice
    ... In fact is it worth bothering at all or are the compilers so good now that they'll do all the optimization for you? ... there is an implementation of the Basic Linear Algebra Subprogram (BLAS) ...
    (comp.lang.fortran)