PHP Performance monitoring Extension xhprof_php tutorial

Source: Internet
Author: User
Tags switches
Xhprof 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. Overall is a good tool, the following is introduced under Ubuntu under the installation and use of the process.

Install Xhprof:

wget http://pecl.php.net/get/xhprof-0.9.2.tgztar zxf xhprof-0.9.2.tgzcd xhprof-0.9.2/extension/sudo phpize./ Configure--with-php-config=/usr/local/php/bin/php-configsudo Makesudo make install

  

In order to view the debug results graphically, you must also install the Graphviz tool, under Ubuntu you can directly use the Apt-get way to install, command: sudo apt-get install Graphviz, if it is other systems, it has to Zigzag point, The command is as follows:

wget http:< span="">< span="">tar zxf graphviz-< span="">. < span="">< span="">-< span="">.  /&&< span="">make install < span="">  < span="">


Configure PHP.ini

Add the following to the php.ini:

[Xhprof]
extension=xhprof.so;
; Directory used by default implementation of the Ixhprofruns
; Interface (namely, the Xhprofruns_default Class) for storing
; Xhprof runs.
;
; xhprof.output_dir=
Xhprof.output_dir=/tmp/xhprof
Note: If the 64-bit system needs to copy the xhprof.so file to the relevant Lib directory (LIB64)

After the change to restart the next Apache, look at the phpinfo, there should be xhprof information about it.

Add the code to the PHP you want to test

 
  Save_run ($data, "xhprof"); Var_dump ($run _id); View Run results

  

Copy the xhprof_lib&&xhprof_html related directory to the address you can access

Visit xxx/xhprof_html/index.php?run= $run _id can see your PHP code to run the situation, where $run_id is the output of the above page, remember must include

Xhprof_lib under the two files, if you do not want to pass this way can also directly output the relevant printing information, that is, directly print_r the above $data value.

http://www.bkjia.com/PHPjc/748243.html www.bkjia.com true http://www.bkjia.com/PHPjc/748243.html techarticle Xhprof 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 ...

  • 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.