xhprof调试PHP

安装:
下载xhprof
wget  http://pecl.php.net/get/xhprof-0.9.2.tgz
解压文件
tar xvf xhprof-0.9.2.tgz
cd xhprof-0.9.2
copy   xhprof_html   xhprof_lib到web目录下我的为/www/xhprof
cp -r xhprof_html/ xhprof_lib/ www/xhprof/
安装三部曲
cd extension/
phpize
./configure  --prefix=/usr/local/xhprof
make
make install
安装完成
编辑php.ini
添加
[xhprof]
extension=xhprof.so
xhprof.output_dir=/www/xhprof/log 
安装graphviz,一个画图工具
wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.26.3.tar.gz
tar zxf graphviz-2.24.0.tar.gz
cd graphviz-2.26.3
./configure
make && make install


开始测试
头部:
xhprof_enable(); 
//xhprof_enable(XHPROF_FLAGS_NO_BUILTINS); 不记录内置的函数
//xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);   同时分析CPU和Mem的开销
$xhprof_on = true;

尾部:
if($xhprof_on){
$xhprof_data = xhprof_disable();
$xhprof_root = '/www/www.hx.com/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, "hx");




你可能感兴趣的:(PHP,调试,xhprof)