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 '