Xhprof makes a Profiler for your PHP Program

Source: Internet
Author: User
Xhprof is an open-source PHP code "tracking" program in Fackbook. It can generate a "function" Call diagram of the php program, as well as the number and time of each "function" call. Now, xhprof has been included in the PECL library of PHP and can be installed via peclinstallxhprof (You may be prompted to use a name with a version number, for example, pec #

Xhprof is an open-source PHP code "tracking" program in Fackbook. It can generate a "function" Call diagram of the php program, as well as the number and time of each "function" call. Now, xhprof has been included in the PECL library of PHP and can install xhprof via pecl install (You may be prompted to use a name with a version number, such as pecl ins

Xhprof is an open-source PHP code "tracking" program in Fackbook. It can generate a "function" Call diagram of the php program, as well as the number and time of each "function" call.

Now, xhprof has been in the php pecl library, you can install xhprof via pecl install (may prompt you to use a name with a version number, such as pecl install xhprof-0.9.2 ).

You can also download the source code for compilation and installation (in fact, it is the same as making the pecl installation effect ).

When using php 5.4, installing xhprof may be in trouble, see this bug announcement for details: https://bugs.php.net/bug.php? Id = 61674, patch the xhprof-0.9.2 to compile through: https://github.com/facebook/xhprof/commit/a6bae51236.diff

The following describes how to use xhprof.

Configure xhprof:
Add to the original php configuration file
[Xhprof]
Extension = xhprof. so
Xhprof. output_dir = '/var/tmp'

The/var/tmp directory must be writable by the apache running account.

Install the drawing tool graphviz, which is called by xhprof for drawing.

You can use yum to directly install: yum install graphviz on RHEL6. Or compile and install it by yourself.

Configure a dedicated web access path for xhprof:

For example, create an xhprof. conf configuration file under/etc/http/conf. d/. The content is as follows:

Alias/xhprof // usr/share/pear/xhprof_html/

Options-indexes
Order allow, deny
Allow from all

Use xhprof:

// Put the first line at the beginning of the program
Xhprof_enable ();

// The original program starts

// The original program ends.

// Put it at the end
$ Xhprof_data = xhprof_disable ();

$ XHPROF_ROOT = '/usr/share/pear /';
Include_once $ XHPROF_ROOT. "/xhprof_lib/utils/xhprof_lib.php ";
Include_once $ XHPROF_ROOT. "/xhprof_lib/utils/xhprof_runs.php ";

$ Xhprof_runs = new XHProfRuns_Default ();

$ Run_id = $ xhprof_runs-> save_run ($ xhprof_data, "xhprof_foo ");

Access statistics:

Http://www.bsdmap.com/xhprof/index.php? Run = $ run_id & source = xhprof_foo

Run_id is searched in the directory set by xhprof. output_dir.

Here is an example:

Http://www.bsdmap.com/xhprof/index.php? Run = 502e0900004815 & source = xhprof_foo

Refer:
Http://hi.baidu.com/thinkinginlamp/blog/item/f4bd08fa1a03ba9e59ee90fd.html
Https://bugs.php.net/bug.php? Id = 61674

Original article address: xhprof -- make a Profiler for your PHP program. Thank you for sharing it with me.

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.