Code Tuning

team bbl


Entire books have been written concerning good programming practices. We will simply present some highlights in the following list for the application developer to consider, especially in light of the preceding advice on "helping" the compiler "see" where optimizations can be most effective:

  • Put the most common statement first when using multiple tests.

  • Avoid unnecessary type conversions (implicit ones as well).

  • Minimize the amount of code actually inside a loop.

  • Minimize the number of expensive operations in a loop (divides, for example). In fact, it would pay to obtain texts specifically about the subject of tuning loops if this is where your bottlenecks reside. A large amount of research is available on the subject.

  • Inline short subroutines.

  • Keep the number of parameters low in subroutines and functions.

  • Use already-tuned libraries of functions where possible instead of creating your own and reinventing the wheel.

  • Eliminate unnecessary I/O and keep I/O operations out of loops where possible.

  • Use parentheses in mathematical expressions to help the compiler, and break complex expressions into simpler subexpressions that can be more easily optimized. Almost always, a better solution is using already-tuned math libraries.

As a reminder, clean, straightforward approaches to a coding problem typically result in the best optimizations and good performance coding practices. Another area to consider is your choice for design.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net