Installing XHProf for Drupal

There are many ways to install XHProf, but at the end of the day, you need to accomplish the same basic set of tasks:

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:

Let PHP know where to find XHProf

This is the simplest step, so I'll just add the details here.

  1. Decide where you'd like XHProf to store its reports. This is usually /tmp, or a subdirectory. E.g. /tmp/xhprof.
  2. Find and open your php.ini file
  3. Enable the XHProf extension and specify the directory for XHProf reports:
    [xhprof] xhprof.output_dir="/tmp/xhprof"

Integrate XHProf with Drupal

Again, you have a few options:

Set up a URL to view the reports

Move xhprof_html into a browser accessible directory.

Understanding the reports

I'd recommend looking here:


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

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.