其他使用参考:

Table of Contents
Toy Production
===================================
参考
KCacheGrind windows 系統下的代替方案
Home php教程 php手册 php扩展xdebug安装以及用kcachegrind系统分析

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

Jun 06, 2016 pm 07:54 PM
php xdebug Install Expand

一:安装 安装方法一:编译安装 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-

一:安装

安装方法一:编译安装

 

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

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

不需要自己拷贝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 

安装成功

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

 

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" 


 

自动安装

[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 = On

xdebug.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"
Copy after login


 

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

2.权限

mkdir -p /tmp/xdebug
chmod 755 /tmp/xdebug
chown www:www /tmp/xdebug

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

3.重启
/usr/local/apache/bin/apachectl  restart

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

说明:如果phpinfo()没有打印这个信息说明没有配置正确!

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

4.停用

说明:如果不分析系统一定要记得关闭xdebug.profiler不然会生成许多文件

xdebug.profiler_enable=off

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

三:分析系统

1.访问你的网站

将首页上各种链接点击几遍,XDebug在/tmp/xdebug目录生成文件

 

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

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

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

 

3.下载图形化工具kcachegrind在windows下的可执行版

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

 

用kcachegrind来看会更形象,注意需要修改从linux中执行的文件的php文件路径,这样就可以了sourcecode.

 

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

查看代码执行顺序

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

 

 更复杂的代码:

<?php define( '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 ) {
            }
        }
    }
    
    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 );
    }
?>



<title>
Toy Factory Output
</title>


  <h1 id="Toy-Production">Toy Production</h1>
  <p>Built  echo PRODUCTION . ' toys' ?></p>


 

Copy after login


分析日志

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

 

其他使用参考: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

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

CakePHP Logging CakePHP Logging Sep 10, 2024 pm 05:26 PM

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles