performance - How to track down slow code in PHP -
i installed open source php project on ubuntu server , got running. however, pages load extremely slow. phpinfo() page , basic test page connecting mysql db load fast. there tons of include files, log files , curl calls in open source code. strategies/tools can use track down source of slowness?
you need profile pages, have performance problems. can done php-extension xdebug , kcachegrind.
follow steps:
- install php5-xdebug package on ubuntu server via:
sudo apt-get install php5-xdebug
. - configure xdebug.profiler_enable_trigger parameter. @ official manual.
- install on local computer kcachegrind package:
sudo apt-get install kcachegrind
. - start slow page
get
parameterxdebug_profile=1
. see related question. - copy generated profile log local comp , open in kcachegrind.
some notes:
- after php5-xdebug package installation you'll need restart http-server (or php-fpm daemon. depends on installed software on server).
- right place profiling procedure test environment, not production.
Comments
Post a Comment