PHP环境下配置WebGrind——让你的网站性能看得见

  今天面试,面试官问我PHP代码怎么去测试其使用性能,我随口一个microtime,测试时间,其实那时候想说一个Wamp下的组件着,结果没记住名字,也想到了Apache的ab.exe,现在想想,唉,这些基本的东西怎么都没记住啊!回来第一件事——玩转这个所谓的PHP性能测试!

  永远记住这个组件的名字——WebGrind。

  1、需要组件环境

    PHP 5.3

    Apache服务器

    xdebug

  我自己用的是Wamp 2.1,不过用什么样的配置方法都是一样的,无非改改PHP.ini,在组件里添加文件。

  闲话少说,正式开始“玩”这个所谓的WebGrind。

  第一步:查看自己的版本中是否存在WebGrind;

    一般wamp的首页有这个选项,当然你也可以通过访问 http://127.0.0.1/webgrind 来查看是否存在;目录在wamp/apps

    当然你也可以下载,自己配置:

    Xdebug下载地址:xdebug http://www.xdebug.org

    WebGrind下载地址:http://code.google.com/p/webgrind/

  第二步,配置php.ini文件:

    找到PHP.ini 中的xdebug,编辑那里的选项,我把所有的off都开启成on了,这样就可以了;我自己又在网上找到别的教程,加上了几句,不知道何用:

; XDEBUG Extension

zend_extension = "H:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9-x86_64.dll"

[xdebug]
;from Internet start
xdebug.auto_trace=on
xdebug.collect_params=on
xdebug.collect_return=on
xdebug.trace_output_dir="H:/wamp/tmp"
;end
xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "H:/wamp/tmp"

  第三步,测试一下,打开本地的任意一个php文件,WebGrind都会自动监测的,然后打开 http://127.0.0.1/webgrind 查看那里的结果

 

原文地址:https://www.cnblogs.com/picaso/p/2512302.html