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 模式,就会触发
mac 下利用 xdebug生成性能报告_第1张图片

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
mac 下利用 xdebug生成性能报告_第2张图片

mac 下利用 xdebug生成性能报告_第3张图片
mac 下利用 xdebug生成性能报告_第4张图片
图片参数占比

funciton name : 函数名
calls: 调用次数
Incl. Wall Time (microsec): 函数运行时间(包括子函数)
IWall%:函数运行时间(包括子函数)占比
Excl. Wall Time (microsec):函数运行时间(不包括子函数)
EWall%:函数运行时间(不包括子函数)

你可能感兴趣的:(php,架构,mac)