Answer the question
In order to leave comments, you need to log in
How to analyze the execution time of a web application?
An existing Facebook application (more simply say, a site written in PHP) has problems with loading speed. He wants to find bottlenecks and understand if I can potentially eliminate them:
1. calls to the Facebook API
2. queries to the database
3. executing a php script
Firebug and others like it are not suitable, so they display the response time in its entirety - it is understandable on client side.
I don’t want to climb all over the code and hang timers to mark the time and fence the bike for analysis. Maybe there are ready-made tools that are deployed on the server side and allow you to perform such an analysis?
Answer the question
In order to leave comments, you need to log in
For "from the inside" (performance of php scripts):
I'm not a php programmer, but I would do this.
would wrap each operation that we want to measure in something like this code
$start = microtime(true);
// Your code goes here.
$end = microtime(true);
echo 'Total script execution time: ', ($end - $start), '.';
if you use php-fpm, then there is a slow log so you don't bother for a long time. well, if you use a framework, then there is usually a built-in benchmark
Judging by the question, you do not use any frameworks, because usually they have either built-in profilers (Symfony) or at least third-party solutions.
Calling the Facebook API can actually be a bottleneck, usually making requests and executing PHP is not as impactful as connecting to a remote server.
It is unnecessary to set timers, although it is worth doing logs during development. There are options to use the PECL APD, which will show detailed statistics on the execution of all functions. It is also a good option to use xdebug. I think the last option will be easier since it only requires enabling profiling in php.ini.
You need profiling in xdebug. Just don't test it on a production server, because profiling heavily loads the system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question