Re: What's more important optimisations or debugging?
- From: "Wilco Dijkstra" <Wilco_dot_Dijkstra@xxxxxxxxxxxx>
- Date: Thu, 31 May 2007 12:00:56 GMT
"David Brown" <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:465e6f47$0$15298$8404b019@xxxxxxxxxxxxxxxxxx
Dave Hansen wrote:
On May 30, 5:15 pm, rhapg...@xxxxxxxxx wrote:
I'm trying to get a feel for what people now consider more important,
optimisations or debugging ability. In the past with such tight memory
limits I would have said optimisations but now with expanded-memory
parts becoming cheaper I would think that debugging ability is more
important in a development tool. It's is not exactly a black and
white question, debug or smallused, but more a ratio. eg. 50% debug/
50% optimised or 70% debug/30% optimised, etc.
The rule is "Make it right, _then_ make it fast." Fast enough is fast
enough. If the optimizer makes your code undebuggable, and you need
the debugger, don't use the optimizer.
Remember Knuth's golden rules about optimisation:
1. Don't do it.
2. (For experts only) Don't do it yet.
I don't agree with this. For small programs it is easy to implement an
efficient algorithm immediately rather than start with an inefficient one.
It's hard to improve badly written code, so rewriting it from scratch
would be better than trying to fix it.
For large programs it is essential that you select the most optimal
architecture and algorithms beforehand, as it is usually impossible to
change them later. The bottlenecks are typically caused by badly
designed interfaces adding too much overhead.
In my experience well designed code is both efficient and easy to
understand, so it wouldn't need optimization (apart from fine tuning).
In other words, if you *need* to optimise an application, you got it wrong.
That applies to hand-tuning of the source code, rather than automatic optimisations in a
compiler, but it's important to remember that the speed of the code is irrelevant if it
does not work.
That said, I generally set my compiler to optimize for space. It
hasn't really caused me any debugging troubles in at least 5 or 10
years. Of course, most of my debug activity resembles inserting
printf statements rather than stepping through code in an emulator.
YMMV.
Yes, a debugger is really only required if you have a nasty pointer bug
overwriting memory etc.
In my experience, it is often much easier to debug code when you have at least some
optimising enabled on the compiler. Code generated with all optimisations off is often
hard to read (for example, local variables may end up on a stack, while register-based
variables can be easier to understand).
Indeed turning off all optimization makes things impossible to debug on
some compilers. I prefer leaving on most optimizations as well.
Wilco
.
- Follow-Ups:
- Re: What's more important optimisations or debugging?
- From: Paul Taylor
- Re: What's more important optimisations or debugging?
- References:
- What's more important optimisations or debugging?
- From: rhapgood
- Re: What's more important optimisations or debugging?
- From: Dave Hansen
- Re: What's more important optimisations or debugging?
- From: David Brown
- What's more important optimisations or debugging?
- Prev by Date: Re: Byte-wise boolean optimisation
- Next by Date: Re: Compact Flash operation by interrupts
- Previous by thread: Re: What's more important optimisations or debugging?
- Next by thread: Re: What's more important optimisations or debugging?
- Index(es):
Relevant Pages
|