Generally speaking, huge performance improvements come from algorithm changes.
Use an ordinary execution profiler (such as gprof or callgrind) to find hot-spots in the code. That will estimate the amount of time spent in each part and direct your attention to highly used code sections. Evaluate issues like:
![]() | Tip |
|---|---|
| Use optimizing compilers and turn on suitable optimization flags. |
![]() | Tip |
|---|---|
| Avoid unnecessary work by caching data |
![]() | Tip |
|---|---|
| Use the correct algorithms |
![]() | Tip |
|---|---|
| Consider favoring algorithms that touch data sequentially |
![]() | Tip |
|---|---|
| Help the compiler by rearranging loops and introducing temporary variables |
![]() | Tip |
|---|---|
| Judiciously break encapsulation to avoid copying data |