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


一、安裝擴展

下載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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM