Updated: Comment #0

Problem/Motivation

Devel setting for xhprof says "Enable profiling of all page views and drush requests."
But running drush on the command line does (appear to) save xhprof results.

Proposed resolution

Steps to reproduce

For MAMP and Drupal 8

  1. git clone/pull drupal 8
  2. git clone/pull drush (make sure on master for d8 compatible) and add drush to your path e.g. cd ~/bin; git clone git@github.com:drush-ops/drush.git
  3. get the source for xhprof (http://pecl.php.net/package/xhprof, the latest one is fine 0.9.4) and put it in the web root e.g. cd ~/foo; curl -O http://pecl.php.net/get/xhprof-0.9.4.tgz; tar xf xhprof-0.9.4.tgz
  4. git clone devel (https://drupal.org/project/devel/git-instructions) and put it in modules dir e.g. cd ~/foo/drupal/modules; git clone --branch 8.x-1.x http://git.drupal.org/project/devel.git
  5. (and/or) pull to get most recent devel e.g. git pull --rebase
  6. get xhprof.so from https://github.com/cam8001/php-xhprof-mamp e.g. for 5.4.4: cd ~/Downloads; curl -O https://github.com/cam8001/php-xhprof-mamp/blob/master/php5.4.4/xhprof.so
  7. copy it to php location e.g. cp ~/Downloads/xhprof.so /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/
  8. edit php ini command line php.ini. find the path with drush php-eval "phpinfo();" > /tmp/phpinfo e.g.: vi /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
  9. also went through the mamp file edit template for php 5.4 ini and put in lines:
    [xhprof]
    extension=xhprof.so
    xhprof.output_dir=/tmp
    
  10. restart servers (in mamp there is a stop/start button)
  11. check phpinfo to see if xhprof is listed, I saw:
    xhprof
    
    xhprof => 0.9.2
    CPU num => 4
    
  12. enable devel from the drupal webroot e.g. cd ~/foo/drupal; drush -y en devel
  13. go to the devel config page: admin/config/development/devel
  14. check the box to enable xhprof "Enable profiling of all page views and drush requests."
  15. note it says *drush*
  16. enter value for xhprof directory e.g. /Users/ctheys/foo/xhprof
  17. enter value for XHProf URL e.g. http://localhost/xhprof/xhprof_html/
  18. save
  19. See link at bottom of page after it saves to "XHProf output." which links to something like http://localhost/xhprof/xhprof_html//index.php?run=52be09b6b8991&source=...
  20. Can go to the XHProf URL e.g. http://localhost/xhprof/xhprof_html/ to see an index of runs.
  21. on the command line, run a drush command e.g. cd ~/foo/drupal; drush -y en views
  22. But the output of the drush command does not give a run id, and the index is not updated with a link to the xhprof info for doing whatever drush did (like enabling views)

Remaining tasks

  • Investigate if this is a drush or devel problem.

User interface changes

No.

API changes

?

Comments

th3m1773n’s picture

Same exact problem with Drupal 7.24, PHP 5.4, Apache 2.2.2, Debian Wheezy

Everything seems to be working fine, the extension is registered with PHP, and enabled in Drupal.

All drush runs are registered in XHProf, and available at the standard xhprof_html URL. This excludes the prospect of a faulty XHProf source, permission issues or misconfigured Devel settings.

However, no standard page runs (on the site itself) are actually saved in the runs folder, or available at the standard URL.

moshe weitzman’s picture

I really want to rip out xhprof support from devel and point folks to xhprof module. please post back here if you have more success there (or failure).

joelpittet’s picture

This is working as advertised here. I've got a suspicion that maybe the command line's PHP is not the same as MAMP, the MAMP xhprof extention is working but the command line isn't.

Try php -i | grep xhprof to see if first xhprof is installed in the command line version.
And second check that they are using the same PHP(which usually they aren't with MAMP because you can switch in MAMP). php -v and which php or php -i | grep php.ini should help determine that with a comparison to the status report page's php. @ /admin/reports/status/php

moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)
moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

xhprof is no longer in devel 7 or 8

basvredeling’s picture

Ran into this same issue. To solve it, I had to find out which php.ini was being used by my mamp installation. Drush cli was using the same PHP but not the same php.ini. MAMP Pro allows you to set some php.ini variables via the GUI but the cli seems to use a generic php.ini located in /Applications/MAMP/conf/php[PHP VERSION]/php.ini
1) Change that php.ini, 2) restart the mamp server, 3) check if the xhprof module is loaded with php -m