Php performance analysis tool, php performance analysis _ PHP Tutorial

Source: Internet
Author: User
Php performance analysis tool. Php performance analysis tool, php performance analysis I. preface useful things should be recorded, and it is also convenient for future queries; this time I will record the installation and use of xhprof; xhprof is facebook's php performance analysis tool.
I. Preface

Record the useful items and facilitate future queries. this time, record the installation and use of xhprof;

Xhprof is a lightweight php performance analysis tool open-source by facebook. it is similar to Xdebug, but has lower performance overhead,

It can also be used in the production environment, or it can be enabled by the program to control whether the profile is performed.

II. Installation
1. wget http://pecl.php.net/get/xhprof-0.9.3.tgz 2. tar zxf xhprof-0.9.3.tgz 3. cd xhprof-0.9.3/extension4./usr/bin/phpize (phpize file generated after php version installation, can be viewed according to phpinfo, so php version is different, the generated phpize is also different, this step mainly generates the configure file) 5 .. /configure-with-php-config =/usr/bin/php-config (php-config path, also the file generated after php installation) 6. make 7. sudo make install (the generated extension file is automatically copied to the extension directory/usr/lib64/php/modules). of course, the specific php file directories vary with each other. you can query them by phpinfo.
III. php. ini configuration
1. find the extension_dir directory 2 (/etc/php. d/xhprof. ini) 3 4 Add the following content: 5 6 extension = xhprof. so7 xhprof. output_dir =/tmp/xhprof // xhprof analysis log
4. restart the service
1 sudo/etc/init. d/http restart2 3 check whether phpinfo is successfully installed
5. usage
1: 2 xhprof_enable (); // enable monitoring 3 // xhprof_enable (enabled); do not record the built-in function 4 // xhprof_enable (XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY ); analyze the CPU and Mem overhead at the same time. 5 6 // code to be tested 7... 8... 9... end of 10 11: 12 $ xhprof_data = xhprof_disable (); // stop monitoring and return running data 13 $ xhprof_root = '/(xhprof's VM directory )/'; 14 // introduce the file 15 include_once $ xhprof_root, which was originally installed in the xhprof virtual host directory. "xhprof_lib/utils/xhprof_lib.php"; 16 export de_once $ xhprof_root. "xhprof_lib/utils/logs"; 17 $ xhprof_runs = new XHProfRuns_Default (); 18 $ run_id = $ xhprof_runs-> save_run ($ xhprof_data, "xhprof "); 19 echo '$ run_id. '& source = xhprof "target =" _ blank "> xhprof Statistics ';

The above code is used to set the virtual host for xhprof.

Copy the xhprof_html and xhprof_lib folders in the source code package to your own virtual directory.

Cp-r xhprof_html xhprof_lib/xxx/xhprof)

After running, click the returned xhprof statistics link.

VI. notes and glossary

On the displayed Statistics page, click [View Full Callgraph] for graphical display (the biggest performance problem is marked in red, followed by yellow );

After you click it, an error message may be displayed. run the following command.

1 yum install -y graphviz2 yum install graphviz-gd

Glossary

1 Function Name 2 Number of Calls to call3 call% call percentage 4 Incl. wall Time (microsec) calls include the percentage of Time consumed by all sub-functions in microseconds (1 million in one second) 5 IWall % calls including the percentage of Time consumed by sub-functions 6 Excl. the Time consumed by the Wall Time (microsec) function execution, excluding the sub-tree execution Time, is calculated in microseconds (1 million in one second) 7 EWall % the percentage of Time consumed by the function execution, the execution time of the subtree is not 8 Incl. the CPU (microsecs) calls the cpu time of all sub-functions. Subtract Incl. wall Time is the waiting Time for the cpu 9 minus Excl. the Wall Time is the waiting Time for the cpu: 10 ICpu % Incl. percentage of CPU (microsecs) 11 Excl. the CPU time consumed by the execution of the cpu (microsec) function, excluding the sub-tree execution time, measured in microseconds (one thousandth second ). 12 ECPU % Excl. Percentage of CPU (microsec) 13 Incl. MemUse (bytes) includes memory used for sub-function execution. 14 IMemUse % Incl. percentage of MemUse (bytes) 15 Excl. memUse (bytes) function execution memory, 16 EMemUse % Excl in bytes. percentage of MemUse (bytes) 17 Incl. peakMemUse (bytes) Incl. memUse peak value 18 IPeakMemUse % Incl. peakMemUse (bytes) peak percentage 19 Excl. peakMemUse (bytes) Excl. memUse peak 20 EPeakMemUse % EMemUse % peak percentage
VII. References
1  http://blog.csdn.net/maitiandaozi/article/details/88962932  http://www.cnblogs.com/wangtao_20/archive/2011/03/16/1986508.html3  http://www.cnblogs.com/wangtao_20/archive/2013/09/13/3320497.html4  5  http://avnpc.com/pages/profiler-php-performance-online-by-xhprof6  http://www.ituring.com.cn/article/1323927  http://www.ituring.com.cn/article/133062?utm_source=tuicool

Summary 1. record the useful items in the preface, which is also convenient for future queries. this time, record the installation and use of xhprof; xhprof is opened on facebook...

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.