原文链接:http://blog.snsgou.com/post-816.html
1、下载xhprof
到这里 http://dev.freshsite.pl/php-extensions/xhprof.html 下载windows版本的xhprof,我这里选择下载
xhprof 0.10.3 for php 5.3 vc9 和 xhprof_html
2、安装xhprof
把压缩包里的 xhprof_0.10.3_php53_vc9.dll 拷贝到php的ext目录下,然后在php.ini配置里面加入配置(不要忘记创建对应的文件夹)
[xhprof]extension=xhprof_0.10.3_php53_vc9.dll; directory used by default implementation of the ixhprofruns; interface (namely, the xhprofruns_default class) for storing; xhprof runs.xhprof.output_dir=d:/php/xhprof/log
3、使用xhprof
将 xhprof_html.zip 解压到你想测试的网站根目录,如我放在了网站目录的 /public/xhprof/windows 下。
测试文件:
0) { bar($x - 1); }}function foo(){ for ($idx = 0; $idx 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 xhprof view
;
当点击链接“[view full callgraph]”时,会报错:
failed to execute cmd: dot -tpng
所以还需要下载图形工具 graphviz。
4、下载graphviz
到这里 http://www.graphviz.org/download_windows.php 下载windows版本的graphviz,我这里选择下载
graphviz-2.38.zip
5、安装graphviz
解压后,把graphviz拷贝到某个目录,如 d:/php/xhprof/graphviz-2.38/
6、配置graphviz
找到上述提到网站目录 /public/xhprof/windows/ 下的 config.php 文件,调整如下:
以上就介绍了给windows + apache 22 + php 53 安装php性能测试工具 xhprof,包括了include方面的内容,希望对php教程有兴趣的朋友有所帮助。
