Hprof is an open source PHP lightweight performance analysis tool for Facebook, similar to Xdebug, but with lower performance overhead, can also be used in production environments or controlled by program switches. Based on Browse
The Performance analysis user interface of the device is easier to view or share results with peers. The call graph can also be drawn. During the data collection phase, it records the number of calls to trace and the inclusive indicator arcs in a dynamic CallGraph program.
It is unique to the reporting/post-processing phase of the data calculation. At data collection, XHPROFD handles recursive function calls by detecting loops and avoids the dead loop by invoking a useful name for each depth in the recursive call.
Xhprof's lightweight nature and aggregation capabilities make it ideal for collecting statistics on performance statistics for "production environments".
1. Installing Xhprof
wget http://pecl.php.net/get/xhprof-0.9.2.tgztar zxf xhprof-0.9. 2 . TGZCD xhprof-0.9. 2 CP -R xhprof_html xhprof_lib <directory_for_htdocs>cd extensionphpize. /Configuremake doinstall
2. Configuring the php.ini File
[Xhprof]extension= for storing; Xhprof runs.; Remember <directory_for_storing_xhprof_runs>web to have write permission Xhprof.output_dir=<directory_for_storing_ Xhprof_runs>
Restart the service for the changes to take effect, you can now use Xhprof, but in order to show more dazzling, it is best to continue to install Graphviz.
3. Installing Graphviz
wget http://tar zxf graphviz-2.26. 3. Tar . GZ cd Graphviz-2.26. 3 . /Configuremake do Install
After the installation is complete, the/usr/local/bin/dot file is generated and you should make sure that the path is in the PATH environment variable so that xhprof can find it.
4. Application Xhprof
//author Http://www.lai18.comXhprof_enable ();//Open Xhprof/** * * Program logic start******/functiontest1 () {Sleep(3); return;}functiontest2 () {test1 ();}functiontest3 () {test2 ();}functionp () {Echo' ;} P (); test3 ();/** * * Program logic end******/$xhprof _data= Xhprof_disable ();//Close xhprof//Save xhprof datainclude_once‘.. /xhprof_lib/utils/xhprof_lib.php ';include_once‘.. /xhprof_lib/utils/xhprof_runs.php ';$xhprof _runs=NewXhprofruns_default ();$xhprof _source= ' Xhprof_test ';$run _id=$xhprof _runs->save_run ($xhprof _data,$xhprof _source);$report _url= ' http://xhprof.rebill.info/index.php?run= '.$run _id.‘ &source= '.$xhprof _source;Echo' <br> ';Echo' View the performance Report:<a href= '.$report _url. ' "target=" _blank ">".$report _url.‘ </a> ';
PHP Performance analysis tool xhprof installation use tutorial