日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

php扩展xdebug安装以及用kcachegrind系统分析

發布時間:2023/11/27 生活经验 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php扩展xdebug安装以及用kcachegrind系统分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一:安裝

安裝方法一:編譯安裝

?

1、下載PHP的XDebug擴展,網址:http://xdebug.org/
# wget http://pecl.php.net/get/xdebug-2.1.2.tgz
# tar -xzf xdebug-2.1.2.tgz
# xdebug-2.1.2
# cd xdebug-2.1.2
# /usr/local/php/bin/phpize
# ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
# make && make install

不需要自己拷貝xdebug.so了,下面可以省。
# cp modules/xdebug.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613

注:/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/不同的PHP版本路徑不同,也不一定要放在該路徑,可以在zend_extension_ts中自行指定xdebug.so所在位置。

================================================

安裝方法二:自動安裝

http://pecl.php.net/package/xdebug

?

#? /usr/local/php/bin/pecl install xdebug?

安裝成功

?

windows下安裝:

需要注意使用custom installation instructions. 將你的phpinfo生成的內容放進去測試 看看下載那個dll

===============================================

二:修改php配置模塊

1.配置

修改php.ini,去除PHP加速模塊,增加以下配置信息支持XDebug擴展

手動安裝

[Xdebug]??
zend_extension_ts="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"?

xdebug.profiler_enable=on?
xdebug.trace_output_dir="/tmp/xdebug"?
xdebug.profiler_output_dir="/tmp/xdebug"?

zend_extension也可以
?

自動安裝

[Xdebug]

extension=xdebug.so

xdebug.profiler_enable=on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.profiler_output_dir="tmp/xdebug"

?

Windows下配置?

?用phpinfo()查看php配置文件位置,增加:

extension=php_xdebug-2.2.0-5.3-vc9.dll[Xdebug];開啟自動跟蹤
xdebug.auto_trace = On
;開啟異常跟蹤
xdebug.show_exception_trace = On
;開啟遠程調試自動啟動
xdebug.remote_autostart = On
;開啟遠程調試
xdebug.remote_enable = On
;收集變量
xdebug.collect_vars = On
;收集返回值
xdebug.collect_return = On
;收集參數
xdebug.collect_params = Onxdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000  xdebug.profiler_enable=on
;xdebug.trace_output_name="%H.%s"
xdebug.trace_output_dir="E:\PHPnow\xdebug"
xdebug.profiler_output_dir="E:\PHPnow\xdebug"


?

------------------------------

2.權限

# mkdir -p /tmp/xdebug
# chmod 755 /tmp/xdebug

注意這個一定要
chown www:www /tmp/xdebug

當前PHPFPM的用戶組在PHPFPM的配置文件

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = nobody
group = nobody


這樣就是,沒有這個不會在tmp目錄生成文件

# chown nobody:nobody /tmp/xdebug

?

正常的運行PHP會生成調試文件

-rw-r--r-- 1 nobody nobody 5758239 Oct 27 14:56 cachegrind.out.29270

-----------------------------

3.重啟
/usr/local/apache/bin/apachectl? restart

?

說明:如果phpinfo()沒有打印這個信息說明沒有配置正確!

------------------------------

4.停用

說明:如果不分析系統一定要記得關閉xdebug.profiler不然會生成許多文件

xdebug.profiler_enable=off

?====================================

三:分析系統

1.訪問你的網站

將首頁上各種鏈接點擊幾遍,XDebug在/tmp/xdebug目錄生成文件

?

2.使用圖形分析工具wincachedgrind分析生成的文件

下載地址:http://sourceforge.net/projects/wincachegrind/files/

?

3.下載圖形化工具kcachegrind在windows下的可執行版

下載地址http://sourceforge.net/projects/precompiledbin/files

?

用kcachegrind來看會更形象,注意需要修改從linux中執行的文件的php文件路徑,這樣就可以了sourcecode.

?

查看代碼執行順序

?

?更復雜的代碼:

<?phpdefine( 'BOOSTER', 5 );define( 'CAPSULE', 2 );define( 'MINUTE', 60 );define( 'STAGE', 3 );define( 'PRODUCTION', 1000 );class Part {function Part() {$this->build( MINUTE );}function build( $delay = 0 ) {if ( $delay <= 0 )return;while ( $delay-- > 0 ) {}}}class Capsule extends Part {function Capsule() {parent::Part();$this->build( CAPSULE * MINUTE );}}class Booster extends Part {function Booster() {parent::Part();$this->build( BOOSTER * MINUTE );}}class Stage extends Part {function Stage() {parent::Part();$this->build( STAGE * MINUTE );}}class SpaceShip {var $booster;var $capsule; var $stages;function SpaceShip( $numberStages = 3 ) {$this->booster = new Booster();$this->capsule = new Capsule();$this->stages = array();while ( $numberStages-- >= 0 ) {$stages[$numberStages] = new Stage();}}}$toys = array();$count = PRODUCTION;while ( $count-- >= 0  ) {$toys[] = new SpaceShip( 2 );}
?><html>
<head>
<title>
Toy Factory Output
</title>
</head>
<body><h1>Toy Production</h1><p>Built <? echo PRODUCTION . ' toys' ?></p>
</body>
</html>


分析日志

?

其他使用參考:xdebug基本使用

===================================

參考

"

為 PHP 應用提速、提速、再提速!,第 2 部分: 分析 PHP 應用程序以查找、診斷和加速運行緩慢的代碼

http://www.ibm.com/developerworks/cn/opensource/os-php-fastapps2/index.html

?

http://hi.baidu.com/%D4%E7%B9%C8%C9%E7%C7%F8/blog/item/d8fedafb7843c66b024f56cb.html

?

使用Xdebug跟蹤代碼執行

http://book.51cto.com/art/200906/126516.htm

KCacheGrind windows 系統下的代替方案

  1. WinCacheGrind
  2. 可分析由xdebug產出的cachegrind.xxx檔,簡易版的kcachegrind。

  3. windows port of kcachegrind
  4. 由原linux的kcachegrind,重新編譯在windows上可執行版,功能與linux kcachegrind相同。

  5. Webgrind
  6. 網頁版的callgrind,搭配xdebug可做即時線上做php script profile。

    ?

    ?

?

===================================?

NetBeans配置Xdebug

http://blog.csdn.net/21aspnet/article/details/6754034

===================================

另外還有一個擴展也很好:

http://pecl.php.net/package/xhprof

安裝參考:

http://www.phpv5.com/blog/archives/66

?

參考:

用 kcachegrind 調優 squid 2.7 筆記

http://blog.sunyixing.com/archives/378

總結

以上是生活随笔為你收集整理的php扩展xdebug安装以及用kcachegrind系统分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。