Developers/Concepts/Doing a performance analysis of a PHP application

From Tine 2.0 - Wiki

< Developers
Screenshot of KCachegrind

While packaging different PHP 5 extensions for the OfficeSpot.Net Collaboration Server, i stumbled upon APD. APD is a debugger and profiler for PHP. Unfortunately the latest release is from 2004. It's extremely unlikely that this extension can still be compiled for PHP 5.

Fortunately i found Xdebug, which is still actively maintained. With Xdebug you can debug your PHP applications (set breakpoints, inspect variables, ...) and you can write profiling data to a file, which can be analysed later with KCachegrind for example.

preparing profiling

Before you can start profiling your application you need to install the Xdebug PHP extension. If you don't have a binary package available you just need to follow the very good documentation at the Xdebug install page.

Users of the OfficeSpot.Net Collaboration Server just need to execute following commands:

sudo apt-get install php5-xdebug

After you have installed the extension you need to add some configuration options to your php.ini file. Users of the OfficeSpot.Net Collaboration Server will find this file at /etc/php5/apache2/php.ini. All you need to add is the following parameter:

xdebug.profiler_enable_trigger = 1

Now you just need to restart the webserver, and everything should be ready for capturing profiling data.

sudo /etc/init.d/apache2 restart

Now you can all any URL on your webserver with the GET/POST parameter XDEBUG_PROFILE set, to get profiling data written to the /tmp directory. You can find more information how to work with Xdebug and KCachegrind at

looking at the results

To get some data to analyse, we displayed the mainscreen of the crm application using this url

The results got written to /tmp/cachegrind.out.5267. You download this file here to have a look at the data yourself. The results are quite interessting. Just have a look at the exported graph.

PHP took about 6.1 seconds to process the main screen. Yes, that's very long. The system is not very fast, because the debugger slows down the webserver and because the system where the webserver is running at, is in running inside VMWare on my laptop, which also slows down things for some reason.

~50% of the time(2,7 seconds) PHP was spending for processing the files included from The other ~50%(3,2 seconds) got spend by the crm application.

The time spent by the crm application(3,2 seconds) can be broken down to:

  • 2,9 seconds doing etemplate layout and data fetching(~0.4 seconds) stuff
  • 0,1 seconds doing egw internal stuff
  • 0,1 seconds processing crm mainscreen


While summarizing this i get the following results:

  • egw api: ~ 3 seconds
  • etemplate: ~ 2.5 seconds
  • crm stuff: ~ 0,5 s seconds

How much i try to improve the speed of the crm application, the crm application will always spent at least 3 seconds(egw api) and 2,5 seconds(doing etemplate stuff).