国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

PHP7下安裝并使用xhprof性能分析工具

瀏覽:29日期:2022-09-07 17:38:51

該 xhprof 版本是從 https://github.com/longxinH/xhprof 獲取

安裝 xhprof

cd xhprof/extension/

phpize

./configure 

make

然后在/etc/php.ini中根據(jù)情況加入

extension=xhprof.so

執(zhí)行

php -m | grep xhprof

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

運(yùn)行

可以直接運(yùn)行從github上clone下來的文件里面example目錄下的那個(gè)例子

輸出如下

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

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

訪問

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

可看見輸出

PHP7下安裝并使用xhprof性能分析工具

點(diǎn)擊中間的 View Full Callgraph 即可看見性能分析圖片

報(bào)錯(cuò)

failed to execute cmd:' dot -Tpng'. stderr:sh: dot:command not found。

//解決方案yum install graphviz

隨機(jī)應(yīng)變

比如想測(cè)試自己的項(xiàng)目,例如一款框架的性能分析。

復(fù)制xhprof_lib/utils/下的兩個(gè)文件

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

// start profilingxhprof_enable();

結(jié)束位置添加

// 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_foon'. '---------------n';

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

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

得到如下所示頁面

PHP7下安裝并使用xhprof性能分析工具

查看圖片

PHP7下安裝并使用xhprof性能分析工具

圖中紅色的部分為性能比較低,耗時(shí)比較長的部分,我們可以根據(jù)根據(jù)哪些函數(shù)被標(biāo)記為紅色對(duì)系統(tǒng)的代碼進(jìn)行優(yōu)化

補(bǔ)充

    Function Name:方法名稱。

    Calls:方法被調(diào)用的次數(shù)。

    Calls%:方法調(diào)用次數(shù)在同級(jí)方法總數(shù)調(diào)用次數(shù)中所占的百分比。

    Incl.Wall Time(microsec):方法執(zhí)行花費(fèi)的時(shí)間,包括子方法的執(zhí)行時(shí)間。(單位:微秒)

    IWall%:方法執(zhí)行花費(fèi)的時(shí)間百分比。

    Excl. Wall Time(microsec):方法本身執(zhí)行花費(fèi)的時(shí)間,不包括子方法的執(zhí)行時(shí)間。(單位:微秒)

    EWall%:方法本身執(zhí)行花費(fèi)的時(shí)間百分比。

    Incl. CPU(microsecs):方法執(zhí)行花費(fèi)的CPU時(shí)間,包括子方法的執(zhí)行時(shí)間。(單位:微秒)

    ICpu%:方法執(zhí)行花費(fèi)的CPU時(shí)間百分比。

    Excl. CPU(microsec):方法本身執(zhí)行花費(fèi)的CPU時(shí)間,不包括子方法的執(zhí)行時(shí)間。(單位:微秒)

    ECPU%:方法本身執(zhí)行花費(fèi)的CPU時(shí)間百分比。

    Incl.MemUse(bytes):方法執(zhí)行占用的內(nèi)存,包括子方法執(zhí)行占用的內(nèi)存。(單位:字節(jié))

    IMemUse%:方法執(zhí)行占用的內(nèi)存百分比。

    Excl.MemUse(bytes):方法本身執(zhí)行占用的內(nèi)存,不包括子方法執(zhí)行占用的內(nèi)存。(單位:字節(jié))

    EMemUse%:方法本身執(zhí)行占用的內(nèi)存百分比。

    Incl.PeakMemUse(bytes):Incl.MemUse峰值。(單位:字節(jié))

    IPeakMemUse%:Incl.MemUse峰值百分比。

    Excl.PeakMemUse(bytes):Excl.MemUse峰值。單位:(字節(jié))

    EPeakMemUse%:Excl.MemUse峰值百分比。

以上就是PHP7下安裝并使用xhprof性能分析工具的詳細(xì)內(nèi)容,更多關(guān)于PHP7下安裝并使用xhprof的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: PHP
相關(guān)文章:
主站蜘蛛池模板: 道孚县| 枣阳市| 莎车县| 利川市| 曲松县| 宿松县| 年辖:市辖区| 加查县| 丰宁| 轮台县| 正镶白旗| 沙河市| 益阳市| 丹凤县| 紫阳县| 武胜县| 泽州县| 潜山县| 邓州市| 新建县| 岳池县| 离岛区| 邢台市| 泸水县| 纳雍县| 贺州市| 彭州市| 富顺县| 云和县| 兴文县| 汽车| 从化市| 迁安市| 舟山市| 佛坪县| 鸡东县| 随州市| 晴隆县| 吴忠市| 右玉县| 定边县|