PHP performance analysis tool XHProf installation and use tutorial, xhprof Installation and Use

Source: Internet
Author: User

PHP performance analysis tool XHProf installation and use tutorial, xhprof Installation and Use
HProf is a lightweight php performance analysis tool open-source by facebook. It is similar to Xdebug, but has lower performance overhead and can be used in production environments, you can also enable or disable profile control. Browser-based


The performance analysis user interface of the tool is easier to view or share the results with colleagues. The call relationship diagram can also be drawn. In the data collection phase, it records call times tracking and inclusive indicator arcs in a dynamic callgraph program.


It is unique in the report/post-processing phase of data computing. During data collection, XHProfd processes recursive function calls through a detection loop, and avoids an endless loop by giving a useful name to calls in every depth in a recursive call.


XHProf's lightweight nature and aggregation feature make it ideal for collecting performance statistics for the "production environment.


1. Install XHProf


wget http://pecl.php.net/get/xhprof-0.9.2.tgztar zxf xhprof-0.9.2.tgzcd xhprof-0.9.2cp -r xhprof_html xhprof_lib <directory_for_htdocs>cd extensionphpize./configuremakemake install


 


2. Configure the php. ini file


[Xhprof] extension = xhprof. so; directory used by default implementation of the iXHProfRuns; interface (namely, the XHProfRuns_Default class) for storing; XHProf runs .; remember that the <directory_for_storing_xhprof_runs> WEB must have the write permission xhprof. output_dir = <directory_for_storing_xhprof_runs>


 


Restart the service to make the modification take effect. Now you can use XHProf. However, it is best to continue to install Graphviz to make the change more effective.


3. Install Graphviz


wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.26.3.tar.gz tar zxf graphviz-2.26.3.tar.gz   cd graphviz-2.26.3  ./configuremake   make install


 


After the installation is complete, the/usr/local/bin/dot file is generated. Make sure that the PATH is in the path environment variable so that XHProf can find it.
4. Apply XHProf

// Author http://www.lai18.comxhprof _ enable (); // open xhprof/****** Program Logic Start ******/function test1 () {sleep (3 ); return;} function test2 () {test1 ();} function test3 () {test2 ();} function p () {echo '



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.