When optimizing an application, you will start by identifying the most time-consuming functions, especially along the application's critical path. As stated in a previous chapter, most of those functions will be I/O functions as these are always the most expensive operations for a computer to execute. Most of the time you will see the possibility to optimize loops and reduce the number of system calls, but you will soon realize that I/O operations remain costly no matter what optimizations you wish to bring to them. Sometimes, though, you might run into very slow PHP structures that can simply be replaced with faster ones, or you may realize that poorly designed code can easily be refactored to be less resource-hungry, such as when replacing a dynamic structure with a simpler static one.
Indeed, dynamic structures should be avoided...