PHP Performance analysis tool-xhprof installation and use

Source: Internet
Author: User
Tags phpinfo

First, preface

Useful things or record it, but also convenient for future inquiries; this time record the installation and use of xhprof;

Xhprof is an open source PHP lightweight performance analysis tool for Facebook, similar to Xdebug, but with lower performance overhead,

It can also be used in a production environment, or it can be controlled by a program switch.

Second, 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      (PHP version after the installation of phpize files, can be viewed according to Phpinfo, so the PHP version is different, the resulting phpize is different, this step mainly generated configure files)5.    /configure  –with-php-config=/usr/bin/php-config      (the path of php-config, also the file generated after PHP installation)  6. Make 7.        sudo make install     (will automatically copy the generated extension files to the extension directory /usr/lib64/php/modules) of    course the specific PHP file directory, everyone is different, Can be queried according to Phpinfo
Three, php.ini configuration
1 find the directory of Extension_dir according to Phpinfo 2 (/etc/php.d/xhprof. INI) 3 4 add a little bit of content: 5 6 extension=xhprof.  So 7 // analysis Log for xhprof
Four, restart the service
1 sudo/etc/init.d/http restart23 See if Phpinfo installed successfully
v. Methods of Use
1 Start:2Xhprof_enable ();//Open Monitoring3 //xhprof_enable (xhprof_flags_no_builtins); built-in functions are not logged4 //xhprof_enable (xhprof_flags_cpu + xhprof_flags_memory); Simultaneous analysis of CPU and mem overhead5 6 //code to be tested7...8...9...Ten  One End: A $xhprof _data= Xhprof_disable ();//stop monitoring, return to run data - $xhprof _root= '/(Xhprof's Virtual host directory)/';  -  //introduce files that were originally installed in the Xhprof virtual host directory the include_once $xhprof _root." Xhprof_lib/utils/xhprof_lib.php ";  - include_once $xhprof _root." Xhprof_lib/utils/xhprof_runs.php ";  - $xhprof _runs=NewXhprofruns_default ();  - $run _id=$xhprof _runs->save_run ($xhprof _data, "Xhprof"); + Echo' <a href= ' http://(Xhprof's virtual host domain name)/xhprof_html/index.php?run= '.$run _id.‘ &source=xhprof "target=" _blank ">xhprof statistics </a>"; 

The above code uses the method to set the virtual host for Xhprof.

Copy the xhprof_html and Xhprof_lib folders in the source bundle to the virtual directory you created

Cp-r xhprof_html xhprof_lib/xxx/xhprof/(The purpose here is to create a data analysis catalog that can be configured as a virtual host access)

After running, statistics click Back to the XHPROF statistics link to be able.

vi. attention issues and noun explanations

In the statistics displayed page, point [View full CallGraph] graphical display (the biggest performance problem will be marked in red, followed by yellow);

After you click, you may be prompted with an error message, execute the following command

1 Yum install-y graphviz2 yum install GRAPHVIZ-GD

noun explanation

1     FunctionName of function name2 number of Calls calls3calls%Call Percentage4Incl. Wall Time(MICROSEC) calls include child functions all spend time in microseconds (one out of 10,000 seconds)5iwall%the percentage of calls that include child functions that take all time6Excl. Wall Time(MICROSEC) The time it takes the function to execute itself, not including the subtree execution time,count in microseconds (one out of 10,000 seconds)7ewall%percentage of time spent by function execution itself, excluding subtree execution time8Incl. CPU (MICROSECS) calls include all CPU time spent by child functions. Minus incl.Wall time is waiting for the CPU9Minus excl.Wall time is waiting for the CPUTenicpu% incl.percent of CPU (Microsecs) OneExcl. CPU (MICROSEC) function executes the CPU time itself, not including subtree execution time,count in microseconds (one out of 10,000 seconds).  Aecpu% Excl.percent of CPU (MICROSEC) -Incl.memuse (bytes) includes the memory used by the child function execution.  -Imemuse% incl.Percentage of Memuse (bytes) theThe Excl.memuse (bytes) function executes its own memory,count in bytes -Ememuse% Excl.Percentage of Memuse (bytes) -Incl.peakmemuse (bytes) incl.Peak of Memuse -Ipeakmemuse% incl.Peak percentage of peakmemuse (bytes) +Excl.peakmemuse (bytes) Excl.Peak of Memuse -epeakmemuse% ememuse% Peak Percentage
Vii. References
 1  http:// blog.csdn.net/maitiandaozi/article/details/8896293  2  http:// www.cnblogs.com/wangtao_20/ archive/2011/03/16/1986508.html  3  http: // www.cnblogs.com/wangtao_20/archive/2013/09/13/3320497.html  4  // avnpc.com/pages/profiler-php-performance-online-by-xhprof  6  http:< Span style= "color: #008000;" >// www.ituring.com.cn/article/133062?utm_source=tuicool   

PHP Performance analysis tool-xhprof installation and use

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.