xhprof php性能分析工具
生活随笔
收集整理的這篇文章主要介紹了
xhprof php性能分析工具
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先安裝libpng* 下載安裝xhprof
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar zxf xhprof-0.9.2.tgz
cd xhprof-0.9.2
cp -r xhprof_html xhprof_lib
cd extension
phpize
./configure
make
make install 編輯php.ini
[xhprof]
extension=xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=/usr/local/nginx/www/pma/xhprof_data?? (需要給777權限)
同時xhprof顯示,也需要proc_open和ini_set 安裝graphviz
Cd /etc/yum.repos.d/ && Wget http://www.graphviz.org/graphviz-rhel.repo
yum install ‘graphviz*’ 配置程序
編輯需要profile的程序,在頂部加入:
xhprof_enable();
//xhprof_enable(XHPROF_FLAGS_NO_BUILTINS); 不記錄內置的函數
//xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); 同時分析CPU和Mem的開銷
$xhprof_on = true; 然后在底部加入:
// stop profiler
$xhprof_data = xhprof_disable(); //
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
//
include_once “./xhprof_lib/utils/xhprof_lib.php”;
include_once “./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”); ; ?>
php -f index.php? 生成4e7bdb6bd8e6b.xhprof_foo數據文件 訪問地址
http://luntan.123.net/dong/xhprof_html/callgraph.php?run=4e7bdb6bd8e6b&source=xhprof_foo&all=1
?
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar zxf xhprof-0.9.2.tgz
cd xhprof-0.9.2
cp -r xhprof_html xhprof_lib
cd extension
phpize
./configure
make
make install 編輯php.ini
[xhprof]
extension=xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=/usr/local/nginx/www/pma/xhprof_data?? (需要給777權限)
同時xhprof顯示,也需要proc_open和ini_set 安裝graphviz
Cd /etc/yum.repos.d/ && Wget http://www.graphviz.org/graphviz-rhel.repo
yum install ‘graphviz*’ 配置程序
編輯需要profile的程序,在頂部加入:
xhprof_enable();
//xhprof_enable(XHPROF_FLAGS_NO_BUILTINS); 不記錄內置的函數
//xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); 同時分析CPU和Mem的開銷
$xhprof_on = true; 然后在底部加入:
// stop profiler
$xhprof_data = xhprof_disable(); //
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
//
include_once “./xhprof_lib/utils/xhprof_lib.php”;
include_once “./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”); ; ?>
php -f index.php? 生成4e7bdb6bd8e6b.xhprof_foo數據文件 訪問地址
http://luntan.123.net/dong/xhprof_html/callgraph.php?run=4e7bdb6bd8e6b&source=xhprof_foo&all=1
?
轉載于:https://blog.51cto.com/liang3391/671850
總結
以上是生活随笔為你收集整理的xhprof php性能分析工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为模拟器linux,华为ENSP模拟器
- 下一篇: 钻井缸套排量_中国石化顺北特深层及川渝页