See drupalquickstart's Channel on Youtube for details on how to debug in Netbeans, and profile with XDebug and Webgrind.

Here's a short version of how to get XHProf to profile your Drupal 7 site.

From the command-line install the devel module with drush:

cd ~/websites/example.dev
drush dl devel
drush pm-enable devel

Then login to the site and configure it: http://example.dev/admin/config/development/devel

Check "Enable profiling of all pages ..."
xhprof directory: /home/quickstart/websites/logs/xhprof
xhprof URL: http://localhost/xhprof
Click "Save"

At the bottom will be a link to "XHProf..."

Click this to view the profile information for that page.

IMPORTANT! While XHProf is on, it will save a profile image for every page load (~ 150k). If you leave it on, these old profiles will start to add up.

To clean out these old profiles, do this:

sudo rm ~/websites/logs/xhprof/*.*

Comments

cmfeliz’s picture

Hello, I followed these instructions, however the following error message is coming out :

Warning: include_once(/home/quickstart/websites/logs/xhpr/xhprof_lib/utils/xhprof_lib.php): failed to open stream: No such file or directory in devel_xhprof_enable() (line 561 of /home/quickstart/websites/test.dev/sites/all/modules/devel/devel.module).
Warning: include_once(): Failed opening '/home/quickstart/websites/logs/xhpr/xhprof_lib/utils/xhprof_lib.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in devel_xhprof_enable() (line 561 of /home/quickstart/websites/test.dev/sites/all/modules/devel/devel.module).
Warning: include_once(/home/quickstart/websites/logs/xhpr/xhprof_lib/utils/xhprof_runs.php): failed to open stream: No such file or directory in devel_xhprof_enable() (line 562 of /home/quickstart/websites/test.dev/sites/all/modules/devel/devel.module).
Warning: include_once(): Failed opening '/home/quickstart/websites/logs/xhpr/xhprof_lib/utils/xhprof_runs.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in devel_xhprof_enable() (line 562 of /home/quickstart/websites/test.dev/sites/all/modules/devel/devel.module).

any suggestion?

Thanks

saltednut’s picture

Also having issues- looks like xhprof is up and running but when I click the link...

Warning: Invalid argument supplied for foreach() in /Users/brantwynn/Sites/xhprof/xhprof_lib/utils/xhprof_lib.php on line 503
Warning: Invalid argument supplied for foreach() in /Users/brantwynn/Sites/xhprof/xhprof_lib/utils/xhprof_lib.php on line 418
Warning: Invalid argument supplied for foreach() in /Users/brantwynn/Sites/xhprof/xhprof_lib/display/xhprof.php on line 931

Any ideas?

jlballes’s picture

+1 !!

1010lex’s picture

Had the same "issue".
Configured "xhprof.output_dir" via ini_set in the monitored Project dynamically. So i needed to configure outputdir for the xhprof UI separately too.

Problem shouldn't occur if your xhprof.output_dir is configured global in php.ini

naiamaya’s picture

I have the same problem. You got to fix it?

elvis2’s picture

When editing the devel settings, like instructed above:
Check "Enable profiling of all pages ..."
xhprof directory: /home/quickstart/websites/logs/xhprof
xhprof URL: http://localhost/xhprof
Click "Save"

I ran into Fatal errors. Fatal error: Class 'XHProfRuns_Default' not found in ...

My problem was related to devel not finding the xhprof class that starts the run and shutdown process.

To solve this problem I had to make sure that my file permissions and ownership were proper.

Here are the commands lines that I used to make this happen:

chmod -R 770 /home/quickstart/websites/logs/profiler
chown quickstart:www-data -R /home/quickstart/websites/logs/profiler
chmod -R 770 /home/quickstart/websites/logs/xhprof
chown quickstart:www-data -R /home/quickstart/websites/logs/xhprof
RobinMofo’s picture

Thank you Elvis2
My xhprof works fine but the "Class missing" message is well annoying .. setting permissions sorted it.

chakrapani’s picture

In this document, there are few configurations which are missing inturn causing different errors.
The following link has a complete instructions for getting xhprof work with Devel :
http://drupal.stackexchange.com/questions/88359/install-and-configure-xh...

Regards
Chakrapani

Shashwat Purav’s picture

Hi

I am getting following errors in the "Recent log messages":

Warning: include_once(): Failed opening '/usr/share/php/xhprof_lib/utils/xhprof_runs.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in devel_xhprof_enable() (line 611 of /*/*/*/sites/all/modules/devel/devel.module).

Warning: include_once(/usr/share/php/xhprof_lib/utils/xhprof_runs.php): failed to open stream: No such file or directory in devel_xhprof_enable() (line 611 of /*/*/*/sites/all/modules/devel/devel.module).

I set the following at "admin/config/development/devel":

xhprof directory: /usr/share/php
xhprof URL: /xhprof_html

Also I am not getting "XHProf output" link at bottom left on the site.

What is the exact problem? permissions? wrong xhprof directory? or something else?

Thank You,
Shashwat Purav

Shashwat Purav’s picture

Resolved the issue. Please find below the key points whoever faces same kind of issue:

> Created "xhprof" directory in the /tmp folder.
> "xhprof_lib" and "xhprof_html" folders should be at same level. At "/usr/share/php" in my case.

Set the following at "admin/config/development/devel":

xhprof directory: /usr/share/php
xhprof URL: /xhprof_html

Flush cache and it works. :)

Thank You,
Shashwat Purav