There are many ways to install XHProf, but at the end of the day, you need to accomplish the same basic set of tasks:
- Install XHProf on your system
- Let PHP know where to find XHProf
- Integrate XHProf with Drupal
- Set up a URL to view the reports
I found all of the various methods a bit overwhelming, so I've put together this page a resource to help you 1) Know the options, and 2) Find corresponding tutorials.
Install XHProf on your system
Here are the basic methods for getting XHProf onto your system:
- Download and compile the source code on your own.
- Use a package installer. Depending on your system, you may want to look at:
- OSX, Homebrew—Check out Installing XHProf on a Mac with Homebrew. Having trouble? I've added a few gotchyas to the troubleshooting section.
- Linux, PEAR—Check out Profiling with XHProf
Let PHP know where to find XHProf
This is the simplest step, so I'll just add the details here.
- Decide where you'd like XHProf to store its reports. This is usually /tmp, or a subdirectory. E.g. /tmp/xhprof.
- Find and open your php.ini file
- Enable the XHProf extension and specify the directory for XHProf reports:
[xhprof]
extension=xhprof.so
xhprof.output_dir="/tmp/xhprof"
Integrate XHProf with Drupal
Again, you have a few options:
- Use Devel module
- Use XHProf module (Drupal 7 only)
- Do it yourself: For a quick and dirty solution, just hack up Drupal's index.php file: Installing XHProf in MAMP for Drupal 6.
Set up a URL to view the reports
Move xhprof_html into a browser accessible directory.
Understanding the reports
I'd recommend looking here: http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/
Troubleshooting
OSX Issues
Are you getting an error like this?
"Cannot find autoheader. Please check your autoconf installation and the
$PHP_AUTOHEADER|$PHP_AUTOCONF environment variable. Then, rerun this script."
You may need to help OSX out by exporting the required variables. I had to add this to my ~/.bash_profile:
export PHP_AUTOCONF=/usr/local/Cellar/autoconf/2.69/bin/autoconf
export PHP_AUTOHEADER=/usr/local/Cellar/autoconf/2.69/bin/autoheader
Are you getting an error like this?
"Error: either we can not find profile data for run_id 50aa620b68b5a or the threshold 0.01 is too small or you do not have 'dot' image generation utility installed."
You need to install Graphviz! See Getting XHProf working well on Mac OS X Lion.
Add new comment