Here's how to add the very useful XHPROF - profiler to your DEVELOPMENT instance of your Drupal site
1. Install the XHPROF on your dev instance in php by downloading it.
http://pecl.php.net/package/xhprof
And installing it manually...
2. Add to the .htaccess file at the bottom =>
php_value auto_prepend_file
/var/www
/xhprof
/header.php
php_value auto_append_file
/var/www
/xhprof
/footer
.php
3. Add these files to where you want on your test setup, and so that it mirrors the above two lines from your .htaccess file =>
footer.php:
<?php
if (extension_loaded('xhprof')) {
$profiler_namespace = "turner";
$xhprof_data = xhprof_disable
();
$xhprof_runs = new XHProfRuns_Default
();
$run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace);
$profiler_url =
sprintf('http://192.168.0.1/xhprof/xhprof_html/index.php?run=%s&source=%s',
$run_id, $profiler_namespace);
printf('<br><br> <a href="%s"
target="_blank">Profiler output</a><br>', $profiler_url);
} else {
echo "<!-- profiler not enabled -->";
}
header.php
:
<?php
if (extension_loaded('xhprof')) {
include_once "/var/www/xhprof/xhprof_lib/utils/xhprof_lib.php";
include_once "/var/www/xhprof/xhprof_lib/utils/xhprof_runs.php";
xhprof_enable
(XHPROF_FLAGS_CPU
+ XHPROF_FLAGS_MEMORY
);
}
*** please note : http://192.168.0.1/xhprof/xhprof_html/index.php - is relative to where you have put your xhprof folders.
4. Add the following to your php.ini =>
extension=xhprof.so
xhprof.output_dir="/tmp"
5. And restart apache2
And now at the bottom of your pages you should have "Profiler output" at the bottom of your pages - click to see the data.
Post new comment