In general, you should avoid premature optimization. This means, do not optimize your code unless you have a performance problem.
Nevertheless, in games, we have two methods (
onDraw) for which the execution time is critical. So, we will be providing a few tips that should be enough to get performance under a reasonable threshold.
For the rest of the cases, your code will be probably good. If you find a performance problem, you should measure it carefully to find where the bottleneck is and only then optimize it. Most of the time, the problem is not where we think it is. Premature optimization can lead to a less readable code without significant improvement.
The creation and destruction of ...