<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="如何安装使用php轻量级的性能分析追踪工具xhprof" id="card1">
<p> 游客</p><p>
标题:如何安装使用php轻量级的性能分析追踪工具xhprof<br/>
正文:<br/>
一、前言　　有用的东西还是记录下来吧，也方便以后的查询；这次记录一下xhprof的安装使用；　　xhprof是facebook开源出来的一个php轻量级的性能分析工具，跟Xdebug类似，但性能开销更低，　　还可以用在生产环境中，也可以由程序开 关来控制是否进行profile。二、安装  wget http://pecl.php.net/get/xhprof-0.9.3.tgz   tar zxf xhprof-0.9.3.tgz   cd xhprof-0.9.3/extension  /usr/bin/phpize  (php版本安装后生成的phpize文件，可根据phpinfo查看，所以php版本不同，生成的phpize也不同，此步骤主要生成configure文件)  ./configure &amp;ndash;with-php-config=/usr/bin/php-config  (php-config的路径，也是php安装后生成的文件)   make   sudo make install  (会自动将生成的扩展文件拷贝到扩展目录中/usr/lib64/php/modules)    当然具体的php文件的目录，每个人不尽相同，可根据phpinfo查询三、php.ini配置根据phpinfo找到 extension_dir的目录（/etc/php.d/xhprof.ini）添加一下内容：extension=xhprof.soxhprof.output_dir=/tmp/xhprof //xhprof的分析日志四、重启服务 sudo /etc/init.d/http restart 查看phpinfo是否安装成功五、使用方法开头：xhprof_enable(); //开启监测 //xhprof_enable(XHPROF_FLAGS_NO_BUILTINS); 不记录内置的函数 //xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); 同时分析CPU和Mem的开销 //要测试的代码.........结尾：$xhprof_data = xhprof_disable(); //停止监测，返回运行数据$xhprof_root = '/（xhprof的虚拟主机目录）<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2174&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2174&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2174&amp;Page=2">[2]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2174&amp;Page=3">[3]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2174&amp;Page=5">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=2174">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=2174">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>