Thursday, June 16, 2011

Code Complete by Steve Mcconnell : Chapter 28

The author focuses on performance tuning of a program in this chapter. Efficiency should be thought of from different viewpoints:

  1. Program Design: The program's architecture should be designed to meet size and speed goals.
  2. Module and Routine Design: The choice of data structures and algorithms affect the performance of modules and routines.
  3. Operating system interactions: Reading files and devices require operating system interaction whose routines might be slow or fat. 
  4. Code compilation: Right programming language and compiler helps optimize the performance.
  5. Hardware:
  6. Code tuning:
The author then tries to resolve some misapprehensions:
  • Reducing the lines of code in a high-level language improves the speed or size of the resulting machine code - false
  • Certain operations are probably faster or smaller than others - false
  • You should optimize as you go - false
  • A fast program is as important as a correct one - false
The author then discuss the 80/20 principle and provide some examples of usage of profiler to improve the performance of a program.

The author then focusses on measuring the code to find hot spots. The author emphasizes on the precision of measurement. The author then advises to choose proper compiler which optimizes correctly.

The author advises to keep all the tuning at the end till the program is complete and correct. The author describes that a single optimization will not achieve the change in performance anybody needs.

The author then discusses about common sources of inefficiency:
  • Input/Output operations
  • Formatted printing routines
  • Floating point operations
  • Paging
  • System calls

No comments:

Post a Comment