ubuntu安装xhprof

1、安装

wget -c http://pecl.php.net/get/xhprof-0.9.2.tgz
tar -xzvf  ./xhprof-0.9.2.tgz
cp ./xhprof-0.9.2.tgz ./www         //xhprof自身带有一个web版的分析页面,放到我的web服务器下面
cd ./xhprof-0.9.2/extension
/usr/local/php/bin/phpize
./configure --enable-xhprof --with-php-config=/usr/local/php/bin/php-config
make && make install
[xhprof]
extension=xhprof.so
xhprof.output_dir=/data/xhprof  //如果不加存放目录的话,默认是放在/tmp下面 (注意:要有写的权限,直接 777 吧)!
service apache2 restart
// 启动xhprof
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); 

各种牛逼的代码。。。。。。。
// 停止xhprof
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = realpath(dirname(__FILE__) . '/..');
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"; 
// 保存统计数据,生成统计ID和source名称
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); //source名称是xhprof_foo

// 查看统计信息
echo "<div style='margin: 50px auto;width:200px;'><a href='../xhprof_html/index.php?run=" . $run_id . "&source=xhprof_foo' target='_blank'>XHProf view</a></s></div>";

2、显示结果
有分表格形式和图片显示各个函数的调用情况
表格的这样些字段

列名 描述
Function Name 方法名称。
Calls 方法被调用的次数。
Calls% 方法调用次数在同级方法总数调用次数中所占的百分比。
Incl.Wall Time (microsec) 方法执行花费的时间,包括子方法的执行时间。(单位:微秒)
IWall% 方法执行花费的时间百分比。
Excl. Wall Time (microsec) 方法本身执行花费的时间,不包括子方法的执行时间。(单位:微秒)
EWall% 方法本身执行花费的时间百分比。
Incl. CPU (microsecs) 方法执行花费的CPU时间,包括子方法的执行时间。(单位:微秒)
ICpu% 方法执行花费的CPU时间百分比。
Excl. CPU (microsec) 方法本身执行花费的CPU时间,不包括子方法的执行时间。(单位:微秒)
ECPU% 方法本身执行花费的CPU时间百分比。
Incl.MemUse (bytes) 方法执行占用的内存,包括子方法执行占用的内存。(单位:字节)
IMemUse% 方法执行占用的内存百分比。
Excl.MemUse (bytes) 方法本身执行占用的内存,不包括子方法执行占用的内存。(单位:字节)
EMemUse% 方法本身执行占用的内存百分比。
Incl.PeakMemUse (bytes) Incl.MemUse峰值。(单位:字节)
IPeakMemUse% Incl.MemUse峰值百分比。
Excl.PeakMemUse (bytes) Excl.MemUse峰值。单位:(字节)
EPeakMemUse% Excl.MemUse峰值百分比。

图片的就需要去安装libpng和graphviz
安装libpng

wget -c http://sourceforge.net/projects/libpng/files/libpng15/1.5.23beta01/libpng-1.5.23beta01.tar.gz/download
tar -xzvf ./libpng-1.5.23beta01.tar.gz
cd ./libpng-1.5.23beta01
./configure
make && make install

安装graphviz

wget -c http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.24.0.tar.gz
tar -xzvf ./graphviz-2.24.0.tar.gz
cd ./graphviz-2.24.0
./configure
make && make install

安装完,重启一下apache
service apache2 restart

在表格页面点击[View Full Callgraph]
就可以以图片形式来展示各个代码段的调用以性能情况

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值