Xhprof is an open source PHP performance monitoring tool for Facebook that takes up little resources and can even be deployed in a production environment. It can be used in conjunction with Graphviz, and can visually display code execution time in the form of pictureswgethttp//pecl.php.net/get/xhprof-0.9.4.tgzTarZXVF xhprof-0.9.4. TGZCD xhprof-0.9.4/extension//usr/bin/phpize./configure--with-php-config=/usr/local/php/bin/php-Config Make&& Make Install# Edit Php.ini:[xhprof]extension=Xhprof.soxhprof.output_dir=/tmp Restart service PHP-fpm Restart # under test<?PHPfunctionMy_dump ($str) {print $str;} Xhprof_enable (); //Start ProfilingMy_dump ('funsion Wu');//Run Program$xhprof _data = xhprof_disable ();//Stop ProfilerPrint_r ($xhprof _data);//Display Raw xhprof data for the profiler run?># Finally, the array is returned, which means the installation is ready. What are the specific values? Forget about it, because there is a configuration of the UI below. It will be intuitive! Yum-YInstallLibjpeg FreeType freetype-devel libjpeg-devel liberation-sans-Fonts.noarch Automatic InstallationYum Install-y Graphviz manual installation:wgethttp//www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.24.0.tar.gzTarZXF graphviz-2.24.0.Tar. GZCD Graphviz-2.24.0./Configure Make&& Make Installwhen the installation is complete, it generates/usr/local/bin/dot file, you should make sure that the path is in the PATH environment variable so that xhprof can find it. VI/root/. Bashrcexport PATH="$PATH:/usr/local/bin/dot"Configure an Access site for Xhprof (virtual host) For example, make a virtual domain name dev.xhprof.com bind to the Xhprof site root directory/usr/local/xhprof-0.9.2/xhprof_html# Find the code you want to analyze, add xhprof_enable () at the beginning of the code; //Start Profiling# Add $xhprof_data at the end of code= Xhprof_disable ();//Stop Profiler, display raw xhprof data for the profiler runInclude_once ("/usr/local/src/xhprof-0.9.4/xhprof_lib/utils/xhprof_lib.php"); # Note Set site Include_path permissions include_once ("/usr/local/src/xhprof-0.9.4/xhprof_lib/utils/xhprof_runs.php"); $xhprof _runs=new \xhprofruns_default ();//Save the run under a namespace "Xhprof_foo".//**note**://by default Save_run () would automatically generate a unique//run ID for you. [You can override this behavior by passing//a run ID (optional arg) to the Save_run () method instead.$run _id = $xhprof _runs->save_run ($xhprof _data,"Xhprof_foo"); $str="\ r \ n------------------\ n". "Assuming you has set up the HTTP based UI for \ r \ n". "xhprof At some address, you can view run at \ r \ n". "http://dev.xhprof.com/index.php?run= $run _id&source=xhprof_foo". "\ r \ n------------------\ n";Echonl2br ($STR); then go to the URL of the program output (e.g. http://Dev.xhprof.com/index.php?run=52c0ea0bef834&source=xhprof_foo), to viewHere are some parameter descriptions inclusive time includes all execution times for child functions. Exclusive Time/the self time function executes itself, not including the subtree execution time. Wall time or wall clock time spent. CPU Time user Consumption+The time the kernel consumes inclusive CPU, including the Cpuexclusive CPU function that is occupied by the sub-function, is consumed by the CPU Click [View full CallGraph] Can be viewed in the form of graphics and text, very convenient to note: Need to use ctype this extension, callgraph image generation relies on some PHP system-level functions, so it is best to remove the function in the php.ini disable
Xhprof Installation Notes (PHP performance monitoring)