Installation and Use of PHP performance monitoring software xhprof (original)

Source: Internet
Author: User

Installation and Use of PHP performance monitoring software xhprof (original)
Author: Yu Chao Email: yuchao86@gmail.com

Xhprof is a lightweight PHP performance analysis tool open-source by Facebook, similar to xdebug. Compared with xdebug, the configuration is simpler, lighter, and more controllable.
Environment: Linux + PHP + Apache
1. Install xhprof
// Download to any directory
[Yuchao @ yuchao-Latitude-E5410 Dev] $ wget http://pecl.php.net/get/xhprof-0.9.2.tgz
// Decompress the file
[Yuchao @ yuchao-Latitude-E5410 Dev] $ tar zxf xhprof-0.9.2.tgz
// Enter the decompressed folder
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CD xhprof-0.9.2
// Copy the two xhprof_html xhprof_lib folders to your webroot directory. The author is/opt/lampp/htdocs.
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CP-r xhprof_html xhprof_lib/opt/lampp/htdocs/xhprof
// Enter the extension folder
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CD Extension
// Execute phpize (the author's phpize is in/user/local/PHP/bin/phpize)
/User/local/PHP/bin/phpize
[Yuchao @ yuchao-Latitude-E5410 extension] $ pwd
/Home/yuchao/dev/xhprof-0.9.2/extension
[Yuchao @ yuchao-Latitude-E5410 extension] $ phpize
[Yuchao @ yuchao-Latitude-E5410 extension] $ ls
Acinclude. m4 config. guess config. m4 configure libtool Makefile. global modules xhprof. c
Aclocal. m4 config. h config. nice configure. in ltmain. sh Makefile. objects php_xhprof.h xhprof. la
Autom4te. cache config. h. in config. status include Makefile missing run-tests.php xhprof. lo
Build config. Log config. sub install-SH makefile. fragments mkinstalldirs tests
[Yuchao @ yuchao-Latitude-E5410 extension] $
[Yuchao @ yuchao-Latitude-E5410 Dev] $./configure
[Yuchao @ yuchao-Latitude-E5410 Dev] $ make
[Yuchao @ yuchao-Latitude-E5410 Dev] $ make test
[Yuchao @ yuchao-Latitude-E5410 Dev] $ sudo make install
After xhprof is installed, you will see the compiled/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/xhprof. So Module
Next, we need to configure PHP. ini so that PHP can load the xhprof. So module compiled by xhprof, and add the following to PhP. ini:
[Xhprof]
Extension = xhprof. So
Xhprof. output_dir =/opt/lampp/var/xhprof/

Note: xhprof. output_dir indicates the directory where the xhprof analysis result is stored.

Now let's test:

The examples directory contains sample. php,

Then run http: // localhost/xhprof/examples/sample. php to generate analysis logs under/opt/lampp/var/xhprof /.

In the 4e6011616b797. xhprof_foo file name, "4e6011616b797" indicates that the logo is changed, that is, the legendary id is changed, and "xhprof_foo" indicates the file suffix.
View the analyzed data

For example, for the data log generated just now, the url address is http: // localhost/xhprof_html/index. php? Run = 4e6038516b797 & source = xhprof_foo

In this way, you will see the statistical data,

Of course, there is also a graphical interface, please Google it yourself.

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.