You are here

XHProf - Install Secrets Revealed ("oooh")

1. 99% of us use macs, so for the Phase 1 of this article I'm sticking to that.
2. I'm not going to go for all the options, I'm going for the fastest, most scalable, most robust and quick results.: MAMP PRO - deal with it.
3. This will involve installing Memcache, XHProf and Homebrew.

INSTRUCTIONES
1. You'll need XCode in your life (for many other things like gcc for other programs), go to the App Store and install it. Make sure you find the installer after it downloads and load it up.
2. Now if you don't have Homebrew you should, I'm even surprised I'm bothering to tell you how but here it is, in the terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

3. Install Memcache, you need this for alot of rad reasons but for this you want it so you can replicate what's on most pro LAMP stacks these days + Mark Sonnabaum says it's a good idea to do so. This is you using Homebrew (the brew commands):

brew install libmemcached
brew install memcached
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/memcached/1.4.7/com.danga.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist

Ok quick cheat (this is more goodness to back why you are reading this article) grab this compiled .so file to give to MAMP...:
Memcache.so Zipped!
Put that file in :
/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

Open your php.ini file and find:
extension=imap.so
extension=gettext.so
extension=mcrypt.so
extension=yaz.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so

add on to this:
extension=memcache.so

I tried restarting apache but had to fully reboot to see memcache showing up in my phpinfo file. Whatev... "Choose the hill you want to die on" Savino says.

4. Hell yez, XHProf... finally... but yet another trick. Homebrew uses Formulas, which presently Homebrew doesn't know that XHProf formula is available and maintained by the Drupal communities very own Mark Sonnabaum. Go here: https://github.com/msonnabaum/homebrew/blob/92f3795d2dcd5e74fb6f47a30b4f...

Or just download it here:
xhprof.rb Zipped!

and put xhprof.rb into this folder: /usr/local/Library/Formula/
Now fire off the simplistic homebrew command:

brew install xhprof
cp /usr/local/Cellar/xhprof/0.9.2/xhprof.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

Go to your php.ini file and at the very very end paste this:
[xhprof]
extension=xhprof.so
; This is the directory that XHProf stores it's profile runs in.
xhprof.output_dir=/tmp

Save the file and refresh Apache. Go to your phpinfo file and search for xhprof, if it's there great - go on to 5., if not make sure you are on the correct php.ini (this is MAMP PRO we are talking about.)

5. (or 4b.?) The actual XHProf php interface built by the crew at Facebook... (you think this is hard, try filtering out the 100 ways you can do this!)
Go to https://github.com/facebook/xhprof to read up... otherwise go to your webroot where you run all your local sites out of ie. ~/htdocs or ~/www or wherever and use...:

git clone https://github.com/facebook/xhprof.git

If you're the slow kid that doesn't have GIT (we're disappointed in you kiddo ;( .):

brew install git

Make a vhost in MAMP PRO, call it xhprof and point the root of the site NOT at the root xhprof folder but at the subfolder xhprof_html so "xhprof/xhprof_html/"

6. Load up Drupal and Devel (Devel supports XHPof out of the box now)! (We're so close) Load up the Devel module (admin/settings/devel) and scroll down the page...
For the "xhprof directory:" field put the top level folder path in there NOT the xhprof_html:
/path/to/facebooks/xhprofui/tool/ijustdownloaded/xhprof
and then for the XHProf URL:
http://xhprof/xhprof_html
SAVE

7. Load up the site... any page... if you have caching and/or performance tweaks on refresh twice... look at the bottom of the page Voila!!!
a XHProf output. link... click that and start profiling.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.