Before we begin, I must caution you: You should only optimize code when performance becomes an issue. Focus on making your code correct. After you have a functioning application and if you suspect performance issues, then diagnose and improve performance. Early optimization can create complex, hard-to-maintain code. It also derails you from quickly implementing features and shipping a finished application.
Even after you’ve built an application, optimization can add hard-to-maintain complexity. The benchmarking tools that you’ll explore in a moment can help you measure performance and decide if the performance improvement justifies the code complexity.
With that out of the way, let’s investigate performance. In this section, you ...