mac 下利用 xdebug生成性能報告

1、安裝 xdebug

https://blog.csdn.net/wangxinxinsj/article/details/104991257

[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_connect_back=0
xdebug.remote_host=0.0.0.0
xdebug.remote_port=9001
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable_trigger_value=666
xdebug.profiler_output_dir=/Users/apple/profile

其中關於性能報告的幾項配置:
profiler_enable 爲 0 關閉自動生成性能報告
profiler_enable_trigger 爲 1 開啓觸發生成性能報告
profiler_enable_trigger_value 觸發性能報告的 “密鑰”,傳輸時會觸發xdebug
profiler_output_dir 性能報告文件目錄

注意,這裏的 profiler_output_dir 目錄的權限一定要給夠

sudo chmod 777 /Users/apple/profile

2、觸發性能分析

2.1 chrome 瀏覽器

安裝 Xdebug Helper,安裝完成,右擊該擴展->選擇 選項 -> 配置 Profile Trigger Value->保存,這個值就是上面的密 666。安裝該擴展需要翻牆。也可自行百度下載該擴展去安裝。
在網頁中點開擴展,選擇 profile 模式,就會觸發
在這裏插入圖片描述

2.2 postman

GET / POST / COOKIE 變量中傳一個 XDEBUG_PROFILE=${TRIGGER_VALUE}
即傳輸一個參數 XDEBUG_PROFILE=666

3、查看性能分析報告

先安裝工具

$ brew install graphviz
$ brew install qcachegrind

進入設置的生成的報告路徑目錄下,輸入命令 qcachegrind

➜  profiler cd /Users/apple/profiler
➜  profiler qcachegrind

File->Open->all files->選中文件->open
在這裏插入圖片描述

在這裏插入圖片描述
在這裏插入圖片描述
圖片參數佔比

funciton name : 函數名
calls: 調用次數
Incl. Wall Time (microsec): 函數運行時間(包括子函數)
IWall%:函數運行時間(包括子函數)佔比
Excl. Wall Time (microsec):函數運行時間(不包括子函數)
EWall%:函數運行時間(不包括子函數)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章