xhprof

克隆代码

git clone https://github.com/phacility/xhprof.git /var/xhprof XHPROF_HOME

安装依赖

pecl install pecl install channel://pecl.php.net/xhprof-0.9.4

配置php.ini

extension=xhprof.so

添加文件 XHPROF_HOME/examples/prepend.php

xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);

添加文件 XHPROF_HOME/examples/append.php

$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");

echo "\n---------------\n".
"http://XHPROF_HOST/index.php?run=$run_id&source=xhprof_foo\n".
"---------------\n";

配置nginx

fastcgi_param PHP_VALUE "auto_prepend_file=XHPROF_HOME/examples/prepend.php \n auto_append_file=XHPROF_HOME/examples/append.php";
Yan Peipan 17 June 2015