使用Xdebug和KCachegrind分析php的discuz!x2.5运行CPU效率
论坛升级到discuz !x2.5,cpu随时都80-90%,load值居高不下,遂寻找一种检查php代码执行效率的方法
找到的方法php5-xdebug扩展或者xhprof扩展,因为服务器是ubuntu的,所以为了方便快捷,直接使用php5-xdebug来调试和分析了
1 xdebug配置
zend_extension=/usr/lib/php5/20090626/xdebug.so xdebug.profiler_enable=on xdebug.trace_output_dir="/tmp/xdebug" xdebug.profiler_output_dir="/tmp/xdebug" xdebug.profiler_output_name = cachegrind.out.%s #cachegrind.out._home_httpd_xxxxx
/tmp/xdebug目录需要手工建立,并且给www用户的读写权限
2 分析xdebug日志
windows环境可以使用WinCacheGrind
下载地址:http://sourceforge.net/projects/wincachegrind/
linux环境使KCachegrind
Leave a Reply
标签云
.htaccess 301 2010 Android apache cache cacti CSS date ddos discuz django fastcgi freebsd git google http iftop linux macos mysql nginx njava php pr python sed seo snmp ssh ubuntu ubuntu10.04 wordpress xdebug 优化 密码 文件 时区 用户 登录 监控 缓存 网站 脚本 颜色
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.