There is a well-known 80-20 law in economics, which is referenced in programming, that is, 80% of the performance bottleneck is caused by 20% of the Code. With the XDebug extension of PHP in Ubuntu, You can effectively find the 20% code. 1. Install configuration 1. Download The XDebug extension of PHP at http://xdebug.org/2、to compile and install xdebugsudotarvxfxdebug-2.1.0.tgzcdxdebug-
There is a well-known 80-20 law in economics, which is referenced in programming, that is, 80% of the performance bottleneck is caused by 20% of the Code.
With the XDebug extension of PHP in Ubuntu, You can effectively find the 20% code.
I. installation and configuration
1. Download PHP XDebug extension, URL: http://xdebug.org/
2. Compile and install XDebug in Ubuntu
Sudo tar vxf xdebug-2.1.0.tgz cd xdebug-2.1.0.tgz
Sudo/usr/local/php/bin/phpize
Sudo./configure -- enable-xdebug -- with-php-config =/usr/local/php/bin/php-config
Sodu make & make install
Note: After installation is complete, there will be an xdebug. so file under/usr/local/php/lib/php/extension/no-debug-non-zts-20090626.
Sodu vim/usr/local/php/lib/php. ini
Modify php. ini and add the following configuration information to support XDebug extension.
Zend_extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xdebug. so
[Xdebug]
Xdebug. auto_trace = On
Xdebug. collect_params = On
Xdebug. collect_return = On
Xdebug. trace_output_dir = "/tmp/xdebug"
Xdebug. profiler_enable = On
Xdebug. profiler_output_dir = "/tmp/xdebug"
Xdebug. profiler_output_name = "cachegrind. out. % c"
Modify folder permissions so that xdebug can write logs in the specified folder
Sudo mkdir-p/tmp/xdebug
Sudo chmod 777/tmp/xdebug
Sudo chown group: user/tmp/xdebug
Sudo/usr/local/apache/bin/apachectl-k restart
At this time, xdebug should have been configured successfully. You can use To view the php information. If the xdebug Column exists, the installation is successful.
At this time, every time you access the PHP file using a web browser, a log file with the corresponding timestamp will be generated and you can view the recorded information.
The log analysis software I use is WinCacheGrind. Because it is for windows, we need to start it with wine.
Next, enter WinCacheGrind to view the execution time of each function ~