Setting up a profiler for your PHP project

Profiling of your PHP coding means that you can create an overview of the performance of your PHP code / project and allows you to detect possible blockades within your code.

The profiler analyse your code and creates an overview of the performance within your code. With the profiler you get an insight view which parts of your code can be optimized in relation to performance.

Default there is no configuration within the PHP development studio for profiling your code. The enable the profiler you need to add some changes to your PHP ini file which is located under <installation dir>/xampp/apache/bin/php.ini

You can add the following settings into your php.ini file to make the profiler work:

xdebug.profiler_enable:
Possible values 1 or 0. When this setting is set to 1 the profiler is enabled, value 0 is means that the profiler is disabled.
Usage: xdebug.profiler_enable=1

IMPORTANT NOTICE: only enable this when you want to create a profile overview. If not disable this setting.

xdebug.profiler_output_dir:
The directory where the 'raw' output data is created. Default this is the system temp directory. We recommend you tot point this directive to a drive which has enough free space. Some large PHP frameworks can create large output files (more then 500mb >>)
Usage: xdebug.profiler_output_dir=c:/temp

xdebug.profiler_output_name:
With this setting you can assign the output file name. This must be prefixed with cachegrind.out
Usage: xdebug.profiler_output_name=cachegrind.out.myproject.%t (this adds a timestamp to the file)

xdebug.profiler_enable_trigger
With this setting you can trigger the profiler with GET / POST parameters setting. If set to 1 the profile information is generated when you use XDEBUG_PROFILE parameter within the GET / POST (set this value to 1). When you are using this parameter you can set the xdebug.profile_enable to 0.

Once you have setup these settings within your PHP.ini the profile output files can be generated. To analyse the profile information you can use the cachegrind for windows application. This programs will give you detailed information of the generated profile file. You can download the cachegrind application for windows from sourceforge or from our site

Once you have installed cachegrind you can view some overview of the generated output files:

With the winCachegrind program you can view/filter/sort and browse through the generated profile information. It can provide you some important information in regards of some bottlenecks within your program code. Also you can use the profiler to analyze for example PHP applications to see how the flow of the code is.