您的位置:首页 > 编程语言 > PHP开发

windows下安装php性能分析工具XHProf

2015-09-19 15:59 736 查看
一、安装扩展

下载XHProf扩展:http://dev.freshsite.pl/php-extensions/xhprof.html

放入扩展文件:下载后解压出.dll文件,拷贝它到php的ext文件夹里面。

开启扩展:php.ini中加入下面的代码

[xhprof]
extension=xhprof.dll
xhprof.output_dir="F:/xhprof/xhprof_log"


二、安装php分析包

这个扩展需要一个php程序来调用。

百度网盘下载:http://pan.baidu.com/s/1pJtck7D

官网下载:pecl.php.net/package/xhprof

下载完毕后解压到 F:/xhprof/xhprof-0.9.4

文件 F:\xhprof\xhprof-0.9.4\examples\sample.php 里面有个基本的例子

// start profiling
xhprof_enable();
//这里是你要分析的代码
/ stop profiler
$xhprof_data = xhprof_disable();
include_once "F:/xhprof/xhprof-0.9.4/xhprof_lib/utils/xhprof_lib.php";
include_once "F:/xhprof/xhprof-0.9.4/xhprof_lib/utils/xhprof_runs.php";
// save raw data for this profiler run using default
// implementation of iXHProfRuns.
$xhprof_runs = new XHProfRuns_Default();
// save the run under a namespace "xhprof_foo"
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_yii"); //导出性能日志 到你安装扩展时候指定的文件夹里面


然后访问你需要分析的代码就可以得到一个日志文件。F:\xhprof\xhprof_log\55fd13b01475f.xhprof_yii.xhprof

三、查看生成的日志

配置一个域名,根目录到 F:\xhprof\xhprof-0.9.4\xhprof_html。

访问域名即可查看刚才生成的日志文件。

资源下载:

xhprof
http://pecl.php.net/package/xhprof http://mirror.facebook.net/facebook/xhprof/doc.html https://github.com/facebook/xhprof
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: