performance optimization of C++

Tools for detect time killer

Tips for Performance Improvement Code Optimization

memory allocate on stack or heap

Allocate memory on stack is more faster then heap cause of different architecture.
The heap is a far more complicated data structure than the stack.

Ref:

vector vs array

Use the right container

Some tips when using C++

1
2
3
4
5
6
7
class Foo
{
const BigObject & bar();
};

BigObject obj = foo.bar(); // OOPS! This creates a copy!
const BigOject &obj = foo.bar(); // does not create a copy

some books

  • Effective C++
  • More Effective C++
  • Effective STL
  • C++ Coding Standards
  • Efficient C++: Performance Programming Techniques

Know some compile and linker options

  • gcc

Reference