xhprof.output_dir string
Directory used by the default implementation of the iXHProfRuns interface (namely, the XHProfRuns_Default class) for storing XHProf runs.
http://php.net/manual/en/xhprof.configuration.php
At the end of profiling (or script) you need to save data manually
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = "/tools/xhprof/";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");
echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing\n";
http://php.net/manual/en/xhprof.examples.php
If you don't want to control profiling in your application code you can make an auto loaded code snippet /path/to/xhprof/xhprof_enabler.php
:
<?php
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
register_shutdown_function(function(){
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = "/path/to/xhprof";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");
echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing";
});
And then add
auto_prepend_file=/path/to/xhprof/xhprof_enabler.php
to /etc/php5/fpm/conf.d/20-xhprof.ini
Please note that you also need to setup a virtual host for profile viewing, or you can just symlink xhprof
folder (which contains xhprof_html
) to your default vhost root.
Restart php5-fpm
and you should be done.