Xhprof 설치 노트 (PHP 성능 모니터링)

6015 단어 PHP
Xhprof facebook       PHP      ,      ,              。

     graphviz  ,                    



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

tar zxvf xhprof-0.9.2.tgz

cd xhprof-0.9.2/extension/

/usr/bin/phpize

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

make && make install



#   php.ini:

[xhprof]

extension = xhprof.so

xhprof.output_dir=/tmp



         service php-fpm restart        



#    

<?php

function my_dump($str) {

 print $str;

}



xhprof_enable();        // start profiling

my_dump('Funsion Wu');    // run program

$xhprof_data = xhprof_disable();    // stop profiler

print_r($xhprof_data);    // display raw xhprof data for the profiler run

?>



#       ,       。             ,     UI   。    !



yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel vixie-cron crontabs readline-devel tk-devel telnet zlib zlib-devel libjpeg freetype freetype-devel lcms lcms-devel tkinter python-tools libjpeg-devel

yum -y install liberation-sans-fonts.noarch 



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

tar zxf graphviz-2.24.0.tar.gz

cd graphviz-2.24.0

./configure

make && make install



     ,    /usr/local/bin/dot   ,        PATH     ,  XHProf    。



 Xhprof        (    )



          xhprof.dev

   xhprof       /usr/local/xhprof-0.9.2/xhprof_html



#

xhprof_enable();    // start profiling



#          

$xhprof_data = xhprof_disable();        // stop profiler, display raw xhprof data for the profiler run

include_once ("/usr/local/xhprof-0.9.2/xhprof_lib/utils/xhprof_lib.php");

include_once ("/usr/local/xhprof-0.9.2/xhprof_lib/utils/xhprof_runs.php");

$xhprof_runs = new XHProfRuns_Default();

// Save the run under a namespace "xhprof_foo".

// **NOTE**:

// By default save_run() will automatically generate a unique

// run id for you. [You can override that behavior by passing

// a run id (optional arg) to the save_run() method instead.]

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

echo "\r
------------------\r
". "Assuming you have set up the http based UI for \r
". "XHProf at some address, you can view run at \r
". "http://xhprof.dev/index.php?run=$run_id&source=xhprof_foo". "\r
------------------\r
"; ( http://xhprof.dev/index.php?run=52c0ea0bef834&source=xhprof_foo ), Inclusive Time 。 Exclusive Time/Self Time , 。 Wall Time 。 CPU Time + Inclusive CPU CPU Exclusive CPU CPU [View Full Callgraph] , : ctype ,Callgraph PHP , , php.ini

좋은 웹페이지 즐겨찾기