What modules do you use in order to profile Magento with XHProf?

I tried:

Other options / approaches?

2 Answers 2


I created my own library for the use of xhprof directly on specific part of Magento code.

 # File lib/Xhprof/Profiler.php
 include_once "/var/www/xhprof/xhprof_lib/utils/xhprof_lib.php";
 include_once "/var/www/xhprof/xhprof_lib/utils/xhprof_runs.php";

 class Xhprof_Profiler
     public static function start()
         xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

     public static function stop()
         $xhprof_data = xhprof_disable();
         if ($xhprof_data) {
             $xhprof_runs = new XHProfRuns_Default();
             $run_id = $xhprof_runs->save_run($xhprof_data, "debug");
         return '<a href="'.Mage::getBaseUrl('direct_link').'xhprof/index.php?run='.$run_id.'&source=debug">xhprof</a>';

After that you could use

<?php Xhprof_Profiler::start() ?> // start profiler
    Your code to profile
<?php echo Xhprof_Profiler::stop() ?> // end profiler

So that everything works here is the installation procedure xhprof on debian server

aptitude install php5-dev make

cd /var/www/
wget https://github.com/facebook/xhprof/archive/master.zip --no-check-certificate
unzip master
mv xhprof-master xhprof
rm -f master
cd xhprof/extension
whereis php-config
./configure --with-php-config=/usr/bin/php-config
make install
make test

vi /etc/php5/conf.d/xhprof.ini

cd /var/tmp/
mkdir xhprof
chown www-data:www-data xhprof

vi virtualhost
Alias /xhprof /var/www/xhprof/xhprof_html
RewriteCond %{REQUEST_URI} !^/xhprof/

It looks there is an extension that offers basic integration:

Here a tutorial how to use it:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.