Using Xdebug to parse thinkphp framework function call Diagram _php Tutorial

Source: Internet
Author: User
Tags netbeans

Using Xdebug to parse thinkphp frame function call graph


Performance tuning is required in development, and the thinkphp framework function call graph is analyzed using Xdebug.

About the installation reference of Xdebug 2 articles

NetBeans Configuration xdebug Remote Debugging PHP

PHP extension xdebug installation and analysis with Kcachegrind system

1. Installing Xdebug

Need to go to http://www.xdebug.org to see some documents, xdebug as a php extension installation

# http://www.xdebug.org/files/xdebug-2.3.3.tgz

# TAR-XZF Xdebug-2.3.3.tgz
# CD xdebug-2.3.3
#/usr/local/php/bin/phpize
#./configure--enable-xdebug--with-php-config=/usr/local/php/bin/php-config
# Make && make install

2. Give permission

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

# chown Nobody:nobody/tmp/xdebug

3. Modify the PHP configuration

Modify the php.ini file

[Xdebug]
Zend_extension=xdebug.so
Xdebug.profiler_enable=on
Xdebug.trace_output_dir=/tmp/xdebug
Xdebug.profiler_output_dir=/tmp/xdebug

4. Restart PHP-FPM

# Killall PHP-FPM

#/ETC/INIT.D/PHP-FPM

5. Run PHP to generate the log

Once configured, running a PHP file generates a log file like this in/tmp/xdebug

-rw-r--r--1 Nobody nobody 4615252 Oct 17:31 cachegrind.out.29293

6. Graphical analysis log using Kcachegrind

Windows Port of Kcachegrind

Each step of the function call looks very clear:

The most serious problem is the execute, which is actually a large number of SQL queries. Called is the number of function calls.

Many optimization methods, using memcached or directly using the thinkphp of their own cache, this is an optimized graph, obviously see called less.

Query cache
Http://document.thinkphp.cn/manual_3_2.html#query_cache
For data queries that don't require high timeliness, we can use the query caching feature to improve performance without having to cache and get it ourselves using caching methods.

The query caching feature supports all databases and supports all caching methods and expiration dates.

When using the query cache, you only need to call the model class's cache method, for example:
1. $Model->cache (True)->where (' Status=1 ')->select ();


SQL Parse Cache
Http://document.thinkphp.cn/manual_3_2.html#sql_build_cache
In addition to query caching, thinkphp supports SQL parsing caching because the thinkphp ORM mechanism, all SQL is generated dynamically and then executed by the database driver.

So if your application has a large number of SQL query requirements, you can turn on SQL parsing caching to reduce SQL resolution to improve performance. To turn on SQL resolution caching, you only need to set:
1. ' Db_sql_build_cache ' = true,
can open database query SQL Create cache, the default cache mode is file mode, also can support XCache and APC way cache, only need to set:
1. ' Db_sql_build_queue ' = ' xcache ',
We know that the amount of query SQL for a project can be very large, so it is necessary to set the queue length under cache, for example, we want the SQL parsing cache to be no more than 20 records, you can set:
1. ' Db_sql_build_length ' =///SQL cache queue Length.

How profilers lie:the cases of gprof and Kcachegrind

Speed up, speed up, and speed up your PHP application! , part 2nd: Analyzing PHP applications to find, diagnose, and accelerate slow-running code

http://www.bkjia.com/PHPjc/1065655.html www.bkjia.com true http://www.bkjia.com/PHPjc/1065655.html techarticle using the XDEBUG Analysis thinkphp framework function call Graph development needs performance tuning, using XDEBUG analysis thinkphp framework function call graph. Reference to the installation of Xdebug this 2 NetBeans configuration xd ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.