XHProf performance analysis tool

Source: Internet
Author: User
Tags zts
XHProf performance analysis tool

Install xhprof:

123 Wget http://pecl.php.net/get/xhprof-0.9.2.tgztar zxf xhprof-0.9.2.tgzcd xhprof-0.9.2


Copy the display file to the website you want to test

12345 Cp-r xhprof_html xhprof_lib/www/www.hx.com/xhprof/cd extension // usr/local/webserver/php/bin/phpize. /configure -- with-php-config =/usr/local/webserver/php/bin/php-configmake & make install


Prompt after installation:

1 Installing shared extensions:/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/

Add in php. ini

1 Extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613 /"

I already have this sentence, so I can add the following two sentences.


12 Extension = xhprof. soxhprof. output_dir =/www/logs/xhprof

The analysis logs are output in the/www/logs/xhprof directory.


Reload the php configuration file and restart the web

12 /Usr/local/webserver/php/sbin/php-fpm reload/usr/local/webserver/nginx/sbin/nginx-s reload

Refresh the phpinfo page and you will see xhprof information in the output.
Xhprof 0.9.2
CPU num 2

Install graphviz, a drawing tool

12345 Wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.24.0.tar.gztar zxf graphviz-2.24.0.tar.gzcd graphviz-2.24.0./configuremake & make install


Program example
Header:

1234 Xhprof_enable (); // xhprof_enable (writable); built-in functions are not recorded // xhprof_enable (XHPROF_FLAGS_CPU + memory); CPU and Mem overhead analyzed at the same time $ xhprof_on = true;


I think it is enough to use xhprof_enable (); and only count the running Time (Wall Time ).

Production environment:

1234 If (mt_rand (1, 10000) = 1) {xhprof_enable (); $ xhprof_on = true ;}

Tail:

123456789 If ($ xhprof_on) {$ xhprof_data = xhprof_disable (); $ xhprof_root = '/www/www.hx.com/xhprof/'{{de_once}xhprof_root. "xhprof_lib/utils/xhprof_lib.php"; include_once $ xhprof_root. "xhprof_lib/utils/logs"; $ xhprof_runs = Running (); $ run_id = $ xhprof_runs-> save_run ($ xhprof_data, "hx"); echo 'http: // 192.168.1.158: 858/xhprof/xhprof_html/index. php? Run = '. $ run_id.' & source = hx "target =" _ blank "> Statistics ';}

Run the program and the statistical words appear at the bottom. click it to view the performance analysis. Sort by running time, and it is easy to find the function with the longest time.
Click [View Full Callgraph] for graphical display. the biggest performance problem is marked in red, followed by yellow, which is obvious.

Terms:
Function Name

Number of CILS Calls

Cballs % call percentage

Incl. Wall Time (microsec) calls include subfunctions that take microseconds (1 million S)

IWall % percentage of time consumed by calling the sub-function

Excl. Wall Time (microsec) the Time it takes to execute the function, excluding the sub-tree execution Time, in microseconds (1 million in one second)

EWall % percentage of time consumed by the function execution, excluding the subtree execution time

Incl. CPU (microsecs) includes the cpu time spent by all sub-functions. Reducing Incl. Wall Time is the Time to wait for the cpu.

Minus Excl. Wall Time is the Time to wait for the cpu.

ICpu % Incl. Percentage of CPU (microsecs)

Excl. CPU (microsec) the cpu time consumed by the function execution, excluding the sub-tree execution time, measured in microseconds (1 million in one second ).

ECPU % Excl. Percentage of CPU (microsec)

Incl. MemUse (bytes) includes the memory used for sub-function execution.

IMemUse % Incl. MemUse (bytes) percentage

Excl. MemUse (bytes) function execution memory, in bytes

EMemUse % Excl. MemUse (bytes) percentage

Peak value of Incl. PeakMemUse (bytes) Incl. MemUse

Peak percentage of IPeakMemUse % Incl. PeakMemUse (bytes)

Peak value of Excl. PeakMemUse (bytes) Excl. MemUse

EPeakMemUse % EMemUse % peak percentage

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.