Measure twice, cut once!
The saying, “Measure twice, cut once,” is popular among carpenters. Cutting a wooden plank is irreversible, and if the resulting plank is too short due to inaccurate measurements, the carpenter must start over with a new plank.
Thanks to Source Code Management (SCM) software such as Git, code changes are not irreversible in the way that cutting wood is. But you will waste precious time if you start optimizing without a plan.
Always measure before you take actions
If you find a performance problem in your application, you may feel the urge to optimize it somehow. However, making code changes by following gut feelings is a bad idea, as you will most likely not end up optimizing the actual code responsible for the slow performance, instead just making assumptions about which part of the code may be slow.
So, before you dive into the code and try your best to make it faster, you should at least start measuring the times taken by different...