I have a web application written in PHP. It uses MySQL to store data. Today I decided to profile it to find bottlenecks in the code and find which parts of it work more slowly than others. Plain stuff. I did a lot of work, and now my page loads in less than 0.05 seconds on my desktop.
But now my profiler tells me that half of this time my application is busy building classes. Frontthe controllers require classes Config, Databaseand User, they have their own stuff to do in __construct(), then it loads the controller Page, which loads Cacheand View, and after that it starts the method main() Page. And all this takes 50% of the total working time. The remaining 50% is used to query db, the results of juggling queries and outputting them to View.
Question: is this normal? "50% for construction"? Does this mean that I have optimized my application well? I was taught that the most time-consuming operations for web applications are database queries. I optimized them, applied some caches, and now they are completely controlled. And I really don't know how to optimize class building. Should I try to optimize these methods __construct()or leave them?
n1313 source
share