Wincachegrind with Xdebug to analyze PHP program performance

Source: Internet
Author: User

Using Wincachegrind to analyze the execution time and efficiency of PHP, you need to install the xdebug extension. If you do not understand xdebug, please first read the "PHP debugging tool Xdebug Installation and use" this article.

Wincachegrind is the Profile Viewer program under Windows. The so-called profile, is the program or software to save the file information, here is the xdebug generated log file. Wincachegrind:http://sourceforge.net/projects/wincachegrind Xingcheng Fayon Gift

As mentioned earlier, this article has described the configuration of php.ini when using Xdebug. However, even if the Xdebug configuration is complete, wincachegrind may not be able to use. Make sure there are two configurations in the php.ini file:

View Source print?
1 ;xdebug.profiler_enable = 0 //默认是0,要改掉
2 xdebug.profiler_enable = on
3 ;xdebug.profiler_output_name = "xdebug_profile.%R::%u"//这个格式WinCacheGrind用不了
4 xdebug.profiler_output_name = "cachegrind.out.%p"

By adding these two lines, the Wincachegrind can be used. Fill in a whole:

View Source print?
1 extension=php_xdebug.dll
2 xdebug.profiler_enable=on
3 xdebug.trace_output_dir="X:\Projects\xdebug"
4 xdebug.profiler_output_dir="X:\Projects\xdebug"
5 xdebug.profiler_output_name = "cachegrind.out.%p"

The last line is mainly for integration with Wincachegrind.out.

Open the Wincachegrind and set "Tools" = "Options" and "Main" working flolder to the path Xdebug directory specified in php.ini. Then refresh the local page, you should be able to see the following monitoring files.

Open the cachegrind.out.* generated in that directory to see how long each procedure call was executed.

It's easier to use, expand the left side of the tree menu, find the most time-consuming operation, and then find the code, you can start to target optimization. For example, the next face of the CI framework of an application for performance analysis.

Wincachegrind with Xdebug to analyze PHP program performance

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.