Skip to content

Instantly share code, notes, and snippets.

@perifer
Created October 31, 2011 15:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/1327738 to your computer and use it in GitHub Desktop.
Save perifer/1327738 to your computer and use it in GitHub Desktop.
Install XHProf

1. Download and install latest version:

cd ~/Projects
git clone https://github.com/facebook/xhprof.git xhprof.YOURDOMAIN
cd xhprof.YOURDOMAIN/extension
phpize
CFLAGS="-arch x86_64 -arch i386"
./configure
make
sudo make install

There is an issue with timers, see https://github.com/facebook/xhprof/commit/b7b4ad7d1b72803fa8235e988d6cbf93d80ed59d#L2R276 You can confirm this by running:

make test

Make the web interface available by aliasing it to public_html:

cd ..
ln -s xhprof_html public_html
```

## 2. Now add the xhprof extension to /etc/php.ini:

```ini
[xhprof]
extension=xhprof.so
xhprof.output_dir=/private/tmp
```

## 3. Restart Apache and double-check that the xhprof extension is properly loading
```bash
sudo apachectl restart  
php -m | grep xhprof  
```

## 4. Add this to devel settings (replace USER with your username):

xhprof directory:

    /Users/USER/Projects/xhprof.YOURDOMAIN

XHProf URL:
    
    http://xhprof.YOURDOMAIN

## 5. To be able to generate callgraphs:

```bash
brew install graphviz
```

See http://xhprof.YOURDOMAIN/docs for documentation on using XHProf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment