国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

php7下xhprof性能分析工具的安裝與使用的圖文代碼教程

2020-03-22 18:49:44
字體:
來源:轉載
供稿:網友


安裝 xhprof
cd xhprof/extension/phpize./configure makemake install

然后在/etc/php.ini中根據情況加入

extension=xhprof.so

執行

php -m | grep xhprof

可以看見輸出,說明php擴展安裝成功,然后重啟Apache或者php-fpm

運行

可以直接運行從github上clone下來的文件里面example目錄下的那個例子

輸出如下

Array(    [main()] => Array        (            [ct] => 1            [wt] => 9        ))---------------Assuming you have set up the http based UI for XHProf at some address, you can view run at http://<xhprof-ui-address>/index.php?run=592567308784c&source=xhprof_foo---------------

然后復制index.php后面的?run=592567308784c&source=xhprof_foo

訪問

xhprof_html/index.php?run=592567308784c&source=xhprof_foo

可看見輸出

圖示

點擊中間的 View Full Callgraph 即可看見性能分析圖片

報錯
failed to execute cmd:" dot -Tpng". stderr:sh: dot:command not found。
//解決方案yum install graphviz
隨機應變

比如想測試自己的項目,例如一款框架的性能分析。

復制xhprof_lib/utils/下的兩個文件

xhprof_lib.php和xhprof_runs.php到入口文件同級目錄,然后在入口文件起始位置添加

// start profilingxhprof_enable();

結束位置添加

// stop profiler$xhprof_data = xhprof_disable();// display raw xhprof data for the profiler runprint_r($xhprof_data);include_once "xhprof_lib.php";include_once "xhprof_runs.php";// save raw data for this profiler run using default// implementation of iXHProfRuns.$xhprof_runs = new XHProfRuns_Default();// save the run under a namespace "xhprof_foo"$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");echo "---------------/n".     "Assuming you have set up the http based UI for /n".     "XHProf at some address, you can view run at /n".     "http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo/n".     "---------------/n";

即可得到如上所示的那個url,然后再次去訪問

http://***/xhprof_html/index.php?run=*****&source=xhprof_foo

得到如下所示頁面

圖示

查看圖片

圖示

圖中紅色的部分為性能比較低,耗時比較長的部分,我們可以根據根據哪些函數被標記為紅色對系統的代碼進行優化

補充
    Function Name:方法名稱。    Calls:方法被調用的次數。    Calls%:方法調用次數在同級方法總數調用次數中所占的百分比。    Incl.Wall Time(microsec):方法執行花費的時間,包括子方法的執行時間。(單位:微秒)    IWall%:方法執行花費的時間百分比。    Excl. Wall Time(microsec):方法本身執行花費的時間,不包括子方法的執行時間。(單位:微秒)    EWall%:方法本身執行花費的時間百分比。    Incl. CPU(microsecs):方法執行花費的CPU時間,包括子方法的執行時間。(單位:微秒)    ICpu%:方法執行花費的CPU時間百分比。    Excl. CPU(microsec):方法本身執行花費的CPU時間,不包括子方法的執行時間。(單位:微秒)    ECPU%:方法本身執行花費的CPU時間百分比。    Incl.MemUse(bytes):方法執行占用的內存,包括子方法執行占用的內存。(單位:字節)    IMemUse%:方法執行占用的內存百分比。    Excl.MemUse(bytes):方法本身執行占用的內存,不包括子方法執行占用的內存。(單位:字節)    EMemUse%:方法本身執行占用的內存百分比。    Incl.PeakMemUse(bytes):Incl.MemUse峰值。(單位:字節)    IPeakMemUse%:Incl.MemUse峰值百分比。    Excl.PeakMemUse(bytes):Excl.MemUse峰值。單位:(字節)    EPeakMemUse%:Excl.MemUse峰值百分比。

以上就是php7下xhprof性能分析工具的安裝與使用的圖文代碼教程的詳細內容,更多請關注 其它相關文章!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西城区| 马尔康县| 当雄县| 新巴尔虎右旗| 阿鲁科尔沁旗| 浦东新区| 宜都市| 屏南县| 临漳县| 汉阴县| 抚顺县| 铁力市| 谷城县| 修武县| 巫山县| 图片| 荃湾区| 夏河县| 六盘水市| 云浮市| 无锡市| 江安县| 普宁市| 西丰县| 绥江县| 高雄市| 杭州市| 璧山县| 手游| 年辖:市辖区| 临沧市| 留坝县| 神木县| 朝阳区| 乌什县| 十堰市| 察雅县| 辽阳县| 孝义市| 武乡县| 嘉定区|