一個(gè)是用于生成 C 函數(shù)調(diào)用樹的 cflow 或者 calltree,下文主要介紹 cflow。
一個(gè)處理 dot 文本圖形語言的工具,由 graphviz 提升。
一個(gè)用于把 C 函數(shù)調(diào)用樹轉(zhuǎn)換為 dot 格式的腳本:tree2dotx
以 Ubuntu 為例,分別安裝它們:
sudo apt-get install cflow graphviz
接下來安裝 tree2dotx 和 Callgraph,這里都默認(rèn)安裝到 /usr/local/bin。
wget -c https://github.com/tinyclub/linux-0.11-lab/raw/master/tools/tree2dotx
wget -c https://github.com/tinyclub/linux-0.11-lab/raw/master/tools/callgraph
sudo cp tree2dotx callgraph /usr/local/bin
sudo chmod x /usr/local/bin/{tree2dotx,callgraph}
接下來展示兩張效果圖:
侵入式:
侵入式使用的 xhgui 需要用到 mongodb
安裝xhgui
git clone git@github.com:perftools/xhgui.git
配置Nginx
server {
listen 80;
server_name site.localhost;
root /Users/markstory/Sites/awesome-thing/app/webroot/;
fastcgi_param PHP_VALUE "auto_prepend_file=/home/www/xhgui/external/header.php"; #這里依據(jù)個(gè)人目錄而配
}
這里的意思是在執(zhí)行項(xiàng)目php代碼前 先執(zhí)行 header.php,從而達(dá)到非侵入式檢測(cè)性能的目的
xhgui配置(生成日志的頻率)
在xhgui的config/config.default.php中,可設(shè)置采樣命中次數(shù);
return rand(1, 100) === 42; 為1%%u7684采樣率,改成return True;則標(biāo)識(shí)每次都采樣
'profiler.enable' => function() {
// url 中包含debug=1則百分百捕獲
if(!empty($_GET['debug'])){
return True;
}else{
// 1%%u91C7樣
return rand(1, 100) === 42;
}
}
mongodb的配置
xhgui/config/config.default.php
// Can be either mongodb or file.
/*
'save.handler' => 'file',
'save.handler.filename' => dirname(__DIR__) . '/cache/' . 'xhgui.data.' . microtime(true) . '_' . substr(md5($url), 0, 6),
*/
'save.handler' => 'mongodb',
// Needed for file save handler. Beware of file locking. You can adujst this file path
// to reduce locking problems (eg uniqid, time ...)
//'save.handler.filename' => __DIR__.'/../data/xhgui_'.date('Ymd').'.dat',
'db.host' => 'mongodb://127.0.0.1:27017',
'db.db' => 'xhprof',
mongo服務(wù)器的配置
mongo
> use xhprof
> db.results.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )
> db.results.ensureIndex( { 'profile.main().wt' : -1 } )
> db.results.ensureIndex( { 'profile.main().mu' : -1 } )
> db.results.ensureIndex( { 'profile.main().cpu' : -1 } )
> db.results.ensureIndex( { 'meta.url' : 1 } )
最后展示幾張xhgui的效果圖
相關(guān)學(xué)習(xí)推薦:PHP編程從入門到精通
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問題,請(qǐng)?jiān)L問西部數(shù)碼官網(wǎng):m.ps-sw.cn