xhprof.output_dir 字符串
iXHProfRuns 接口的默认实现(即 XHProfRuns_Default 类)用于存储 XHProf 运行的目录。
http://php.net/manual/en/xhprof.configuration.php
在分析(或脚本)结束时,您需要手动保存数据
$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
如果您不想控制应用程序代码中的分析,您可以制作一个自动加载的代码片段/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";
});
然后添加
auto_prepend_file=/path/to/xhprof/xhprof_enabler.php
至/etc/php5/fpm/conf.d/20-xhprof.ini
请注意,您还需要设置一个虚拟主机来查看配置文件,或者您可以将xhprof
文件夹(包含xhprof_html
)符号链接到您的默认虚拟主机根目录。
重新启动php5-fpm
,你应该完成。