dcsimg
Linux Today: Linux News On Internet Time.




More on LinuxToday


Freshmeat: Optimization

Oct 08, 2000, 15:13 (4 Talkback[s])
(Other stories by Erik Greenwald)

WEBINAR:
On-Demand

Re-Imagining Linux Platforms to Meet the Needs of Cloud Service Providers


"Many people seem to think that the best road to blindingly fast programs is writing as much as possible in assembly. Typically, this results in buggy software that is actually slower than that written in a higher level language. Premature optimizations can cost huge amounts of time and effort. No optimization should occur before the program works without crashing or exhibiting weird behavior."

"Attempting to optimize a program that doesn't even run is a pointless task. If your program crashes, then not only is it impossible to profile (binaries compiled for profiling write the data file after your program calls exit), but the users won't want to run it. Make sure you have no syntactic or memory errors in your program before even attempting to optimize it. I strongly suggest using all facilities in the language to extend warnings and errors, as well as using tools like lclint and Electric Fence to verify your program will not crash."

"Optimization can often make a program less readable, so you want to guarantee that the program does exactly what it should BEFORE you start optimizing. Any logical bugs should be tracked down and squished. I suggest a lot of test cases, especially at the bounds. "Off by one" errors can be tricky to find in clear code, and virtually impossible in code that has been optimized beyond readability."

Complete Story