xhprof php性能分析
1.clone xhprof 此版本為github第三方擴(kuò)展 (php官房不支持 php 7)
https://github.com/longxinH/xhprof
2.extension 目錄為擴(kuò)展源碼安狀擴(kuò)展即可
phpize ./configure make make install
3.編輯php.ini 啟用xhprof擴(kuò)展
[xhprof] extension = xhprof.so xhprof.output_dir = /tmp/xhprof ;性能分析數(shù)據(jù)文件存放位置 需要php用戶有可寫(xiě)可讀權(quán)限
4.對(duì)項(xiàng)目入口文件添加代碼
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS + XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); register_shutdown_function(function (){ $data = xhprof_disable(); //xhprof_lib 在第一步git clone 后的文件夾里面 include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_lib.php'; include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_runs.php'; $objXhprofRun = new XHProfRuns_Default(); $objXhprofRun->save_run($data, "table"); //生成數(shù)據(jù)文件后綴 });
5.nginx 或者 apache 創(chuàng)建 網(wǎng)占目錄(apache為例)
VirtualHost *:80> ServerName xhprof.com ## xhprof/xhprof_html 在第一步git clone 后的文件夾里面 DocumentRoot "/mnt/d/www/xhprof/xhprof_html" DirectoryIndex index.html index.php index.html Directory "/mnt/d/www/xhprof/xhprof_html"> Options Indexes FollowSymLinks AllowOverride All Require all granted /Directory> /VirtualHost>
6.訪問(wèn) http://xhprof.com/ (上面虛擬主機(jī)配置的 本地域名需要host )顯示每次程序運(yùn)行生成的性能分析數(shù)據(jù)文件 點(diǎn)擊可以打 開(kāi)
7.如果想要查看性能圖點(diǎn)擊 view full callgraph (服務(wù)器需要安裝 graphviz 庫(kù))
ubuntu 安裝方法 (pro apt-get install graphviz
)
8.顯示效果圖
總結(jié)
以上所述是小編給大家介紹的php xhprof使用實(shí)例詳解 ,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
標(biāo)簽:涼山 遼陽(yáng) 昭通 十堰 甘肅 九江 韶關(guān) 梅河口
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《php xhprof使用實(shí)例詳解》,本文關(guān)鍵詞 php,xhprof,使用,實(shí)例,詳解,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。