Profiling a PHP application, 50% of the time it takes to build classes - is this normal?

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?

+3
source share
3 answers

; , , , , , . , , , ; , - , , , .

+3

? , , 50%? .

+2

I had to make some web services integrated into the Drupal website.

So, I ended up doing some profiling to find out that the Drupal boot bin used 90% of the time, and my code took up the remaining 10%. Drupal is poorly designed :) so it loads a lot and a lot of things that it really doesn't use.

I think you decide, in your case.

+2
source

Source: https://habr.com/ru/post/1719812/


All Articles