PHP xprof performance test under CentOS

Source: Internet
Author: User
Tags configuration php

First, the first step, install

1. Installing the xhprof Extension

wget http://pecl.php.net/get/xhprof-0.9.2.tgz

Tar zxvf xhprof-0.9.2.tgz

CD xhprof-0.9.2

Cp-r xhprof_html xhprof_lib <directory_for_htdocs> # The directory where the application is located

CD extension

/usr/local/webserver/php/bin/phpize (if the path is not normal, there is a PHP folder under/usr/local/)

./configure--with-php-config=/usr/local/webserver/php/bin/php-config

Make

Make install

2. Configuration php.ini (php.ini directory usually exists in usr/local/php/etc)

3. For more intuitive tracking to see where the performance is affected, the need for graphical display needs to install dot

#如果要图形话, you need to install dot

wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.24.0.tar.gz

Tar zxvf graphviz-2.24.0.tar.gz

CD graphviz-2.24.0

./configure

Make

Make install

4. Invocation mode

At the beginning of the method, write

Xhprof_enable ();

At the end of the method, write

$xhprof _data = xhprof_disable ();
$XHPROF _root = Realpath (dirname (__file__). /..‘);
Include_once ($XHPROF _root. "/.. /xhprof/xhprof_lib/utils/xhprof_lib.php ");//The path is the address that the xhprof_html store after decompression
Include_once ($XHPROF _root. "/.. /xhprof/xhprof_lib/utils/xhprof_runs.php ")///path Xhprof_runs store address after decompression
$xhprof _runs = new \xhprofruns_default ();
$run _id = $xhprof _runs->save_run ($xhprof _data, "Xhprof_foo");
Echo ' <a href= ' http://xhprof.wst3.meici.com?run= '. $run _id. ' &source=xhprof_foo ' target= "_blank" > Performance analysis </a> ';//output address, which can be viewed at this address or configured by itself

After performing the methods that need to be monitored, you can enter Xhprof.index by configuring the address to view the method execution

Choose a point to go in

After clicking into the graphical interface, it will be displayed as a picture.

Yellow represents a place where execution time is longer and can be optimized

Attach an explanation

For Xhprof's noun explanation:

12345678910111213141516171819202122 Appendixfunction name function name number of Calls calls Calls% call percentage incl. Wall time (microsec) calls include child functions all spend a microsecond count (one out of 10,000 seconds ) IWall% of all elapsed time inclusive child functions called Excl. Wall time (microsec) function execution itself, excluding subtree execution time , in microseconds (one out of 10,000 seconds ) Ewall% of the time spent by the function execution itself, excluding subtree execution time incl. CPU(microsecs) calls include all the CPU time spent by the child functions . Minus incl. Wall time is waiting for the CPU ReducingExcl. Wall time is waiting for the CPU icpu% incl. percent of CPU (microsecs) Excl. the CPU (microsec) function executes its own CPU time, excluding subtree execution time , in microseconds (one out of 10,000 seconds ). ecpu% Excl. percent of CPU (microsec) incl. Memuse(bytes) includes the memory used by the child function execution. imemuse% incl. Percentage of memuse (bytes) Excl. The Memuse(bytes) function executes its own memory , measured 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

PHP xprof performance test under CentOS

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.