Optimal programming advice
- From: Glyn Edwards <glynedwards@xxxxxxxxxxx>
- Date: Wed, 07 Sep 2005 09:36:34 +0100
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
.
- Follow-Ups:
- Re: Optimal programming advice
- From: Brooks Moses
- Re: Optimal programming advice
- From: E. Robert Tisdale
- Re: Optimal programming advice
- From: James Van Buskirk
- Re: Optimal programming advice
- From: Kevin G. Rhoads
- Re: Optimal programming advice
- From: glen herrmannsfeldt
- Re: Optimal programming advice
- From: Pierre Asselin
- Re: Optimal programming advice
- From: David Flower
- Re: Optimal programming advice
- From: Arjen Markus
- Re: Optimal programming advice
- Prev by Date: Re: Strange Problem
- Next by Date: Re: Optimal programming advice
- Previous by thread: for lorrayne: intriguing photos - ic iw uz - (1/1)
- Next by thread: Re: Optimal programming advice
- Index(es):
Relevant Pages
|