Xdebug is a free open source PHP extension and is a developer's powerful tool when it's come to: tracing, profiling, debugging, and creating code coverage statistics. Documentation and installation guide can be found here. To activate xdebug extension we need to open our php.ini file and add these entries:
zend_extension=/path/to/your/php/extension/xdebug.so xdebug.profiler_output_dir=/tmp/xdebug_profile xdebug.profiler_enable_trigger=1 xdebug.profiler_enable=0 xdebug.auto_trace=0 xdebug.collect_params=1 xdebug.collect_return=1 xdebug.collect_vars=1 xdebug.trace_output_name="cachegrind.out.%s.%p.%u" xdebug.profiler_output_name="cachegrind.out.%s.%p.%u" xdebug.trace_format=1 xdebug.extended_info=1
Having restarted your web server because we changed php.ini, you can check
the output of phpinfo() or run php -m at the command line.
In each case, xdebug must be listed twice, once as a PHP extension, and as a Zend extension as well.
We use profiling feature of Xdebug for counting how many times a statement has been excecuted and how much execution time it took. To do that you must put the next URL parameter "?XDEBUG_PROFILE=1" on the page you need to track. In /tmp/xdebug_profile directory you'll have now an "cachegrind.out.%s.%p.%u" file that is not meant for human redability and it can be opened with tools like WinCacheGrind or KCacheGrind.