Before you do any code tuning…
- Choose the right algorithm.
- Choose the right language.
- Implement a correct solution.
The efficiency of non-working software is zero.
What I’m about to cover is a load of tips to be used when you just can’t make your software go fast enough. Many of the techniques will have attendant disadvantages, such as reducing readability.
It’s vital to know your code works before you start trying to rework it. You must have a solid baseline against which to test.