Optimizing C++/Code optimization

From Wikibooks, open books for an open world
Jump to navigation Jump to search

In this chapter some techniques, specific for C++ language, are proposed. They are to be applied only in bottlenecks, as, although they may speed up execution, they also make more complex and less maintainable the source code.

In addition, such guidelines in some cases could worsen the performance instead of improving it, and therefore their effect should be always measured before releasing them.

The optimization techniques are grouped according their goal.

  1. Allocations and deallocations
  2. Run-time support
  3. Instruction count
  4. Constructions and destructions
  5. Pipeline
  6. Memory access
  7. Faster operations
  8. Compile time optimization