First, preface
Useful things or record it, but also convenient for future inquiries; this time record the installation and use of xhprof;
Xhprof is an open source PHP lightweight performance analysis tool for Facebook, similar to Xdebug, but with lower performance overhead,
It can also be used in a production environment, or it can be controlled by a program switch.
Second, installation
1. wget http:
//
pecl.php.net/get/xhprof-0.9.3.tgz 2. Tar zxf xhprof-0.9.3.
tgz 3. CD xhprof-0.9.3/
extension4. /usr/bin/
phpize (PHP version after the installation of phpize files, can be viewed according to Phpinfo, so the PHP version differs, the resulting phpize is different, this step mainly generates configure files) 5. . /configure –with-php-c/bin/php-
config (the path of php-
config, also the file generated after PHP installation) 6
. make 7.
sudo make install (automatically copies the generated extension files to the extended directory /usr/lib64/php/
modules) Of course the specific PHP file directory, everyone is different, can be based on phpinfo query
Three, php.ini configuration
1
Find the directory
of Extension_dir according to Phpinfo
2 (/etc/php.d/xhprof.
INI)
3
4
add a little bit of content:
5
6 extension=xhprof.
so
7 xhprof.output_dir=/tmp/xhprof
//
xhprof analysis Log
Four, restart the service
1 sudo/etc/init.d/
http restart
2
3 See if Phpinfo installed successfully
V. Methods of Use
1
Start:
2Xhprof_enable ();
//
Open Monitoring
3
//xhprof_enable (xhprof_flags_no_builtins); built-in functions are not logged
4
//xhprof_enable (xhprof_flags_cpu + xhprof_flags_memory); Simultaneous analysis of CPU and mem overhead
5
6
//code to be tested
7...
8...
9...
Ten
One
End:
A
$xhprof _data= Xhprof_disable ();
//
stop monitoring, return to run data
-
$xhprof _root= '/(Xhprof's Virtual host directory)/'
;
-
//
introduce files that were originally installed in the Xhprof virtual host directory
the
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"
);
+
Echo' $run _id.' &source=xhprof "target=" _blank ">xhprof statistics"
;
The above code uses the method to set the virtual host for Xhprof.
Copy the xhprof_html and Xhprof_lib folders in the source bundle to the virtual directory you created
Cp-r xhprof_html xhprof_lib/xxx/xhprof/(The purpose here is to create a data analysis catalog that can be configured as a virtual host access)
After running, statistics click Back to the XHPROF statistics link to be able.
Vi. attention issues and noun explanations
In the statistics displayed page, point [View full CallGraph] graphical display (the biggest performance problem will be marked in red, followed by yellow);
After you click, you may be prompted with an error message, execute the following command
1 Yum install-
y graphviz
2 yum install GRAPHVIZ-GD
noun explanation
1
Function
Name of function name
2
number of Calls calls
3calls%
Call Percentage
4Incl. Wall
Time
(MICROSEC) calls include child functions all spend time in microseconds (one out of 10,000 seconds)
5iwall%
the percentage of calls that include child functions that take all time
6Excl. Wall
Time(MICROSEC) The time it takes the function to execute itself, not including the subtree execution time,
count in microseconds (one out of 10,000 seconds)
7ewall%
percentage of time spent by function execution itself, excluding subtree execution time
8Incl. CPU (MICROSECS) calls include all CPU time spent by child functions. Minus incl.
Wall time is waiting for the CPU
9Minus excl.
Wall time is waiting for the CPU
Tenicpu% incl.
percent of CPU (Microsecs)
OneExcl. CPU (MICROSEC) function executes the CPU time itself, not including subtree execution time,
count in microseconds (one out of 10,000 seconds).
Aecpu% Excl.
percent of CPU (MICROSEC)
-Incl.
memuse (bytes) includes the memory used by the child function execution.
-Imemuse% incl.
Percentage of Memuse (bytes)
theThe Excl.memuse (bytes) function executes its own memory,
count 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
Vii. references
1 http:
//
blog.csdn.net/maitiandaozi/article/details/8896293
2 http:
//
www.cnblogs.com/wangtao_20/archive/2011/03/16/1986508.html
3 http:
//
www.cnblogs.com/wangtao_20/archive/2013/09/13/3320497.html
4
5 http:
//
avnpc.com/pages/profiler-php-performance-online-by-xhprof
6 http:
//
Www.ituring.com.cn/article/133062?utm_source=tuicool
The above describes the PHP performance analysis tool-xhprof installation and use, including aspects of the content, want to be interested in PHP tutorial friends helpful.