首页 > Lamp 安装配置, PHP, Ubuntu > ubuntu xdebug kcachegrind

ubuntu xdebug kcachegrind

2010年9月14日 发表评论 阅读评论

What is Xdebug?
The Xdebug extension helps you debugging your PHP scripts by providing a lot of valuable debug information, besides that it gives you the possibility of profiling your Web Applications, this last feature is exactly what I needed.

What is KCachegrind
The profiler in Xdebug outputs profiling information in the form of a cachegrind compatible file, KCachegrind allows you to open such files and present you the results graphically.

To profile your Web Applications you need to do the following:

1) Make sure your Web Application is running in a server you have “sudo” access to
This is because you need to make some configuration changes to it, preferably your local machine or a Staging server.

2) Install, configure Xdebug for PHP5 and generate the profiling output file
In Ubuntu 9.10 (Karmic Koala) you run:
sudo apt-get install php5-xdebug

Then configure Xdebug, in /etc/php5/conf.d/xdebug.ini drop the following lines:
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = “/var/www/xdebug/”

Restart Apache.

This Xdebug settings enable profiling for Web Applications only when you request it via URL like:

http://www.mywebappdomain.com/page_to_profile.html?XDEBUG_PROFILE

So you don’t fill up your hard disk with “profiling” files each time you make a request to your server.

Once you make such request from your browser, Xdebug will generate a file named something like “cachegrind.out.XXXX” in the /tmp directory (this is the default, the output directory can also be changed with the setting xdebug.profiler_output_dir in xdebug.ini).

3) Install KCachegrind and open the file
In Ubuntu run:
sudo apt-get install kcachegrind

The shortcut will show up under Applications > Programming.

Finally, open the file with it.

分类: Lamp 安装配置, PHP, Ubuntu 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.