S
S
sphinks2012-08-08 01:06:02
PHP
sphinks, 2012-08-08 01:06:02

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

6 answer(s)
P
pr0tect0r, 2012-08-08
@sphinks

For "from the inside" (performance of php scripts):

  • xhprof
  • newrelic
  • xdebug

For the outside:
webpagetest.org - a convenient profiler for loading a page from different places, different browsers

F
FanKiLL, 2012-08-08
@FanKiLL

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), '.';

use some kind of logger instead of echo. In general, the usual StopWatch.
This is if you need a quick solution, for a deeper analysis, there are probably good utilities.

H
himik, 2012-08-08
@himik

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

S
Sergey, 2012-08-08
Protko @Fesor

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.

V
Vitaly Zheltyakov, 2012-08-08
@VitaZheltyakov

You need profiling in xdebug. Just don't test it on a production server, because profiling heavily loads the system.

C
charliez, 2012-08-08
@charliez

If there is root access in the system, then you can set system debugging tools like strace on the process. For example, I catch bugs in this way in the scripts of clients complaining about incomprehensible brakes in the work of sites.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question