Performance Optimization Techniques

When optimizing software I use mainly the following techniques. Some of them are generic, some of them are suitable for certaiin types of tasks. Usually the overall performance improvement is in the order of tens to thousands per cent.

Usage of efficient algorithms

The same thing can be done in several ways. Some of the ways are much more efficient than others. By replacing a chunk of code by its more efficient version, a significant performance improvement can be achieved.

Usage of suitable data structures

Certain data structures are suitable for certain tasks. Significant performance improvement can be achieved by replacing the unsuitable data structures by the data structures that are the most suitable for given tasks.

Efficient usage of STL

When using STL (Standard Template Library), there are several principles to make the code more efficient. These principles are simple changes that have relatively big effect.

Parallel processing

Some tasks can be processed in parallel in several threads on several CPUs. The speedup is usually almost proportional to the number of CPUs.

Calculation on graphic cards

Modern graphic cards (GPU) can execute arbitrary code. The GPUs consist of hundrets to thousands of calculation code, therefore they allow massive parallel processing. Ideal task for graphic card performs the same calculation over huge amount of data.

Efficient usage of C++

When using C++, nonnegligible speedup can be achieved by using several simple techniques, for example by passing objects by reference instead of passing objects by value.