背景:

因为近期保护老我的项目,各种factory类,各种parentparent。各种abstract extends,而且依赖我的项目外的许多common和中间件等。IDE内无奈间接跳转,而且急需缕清办法的调用链路。调研后有了以下组件的组合。
此文不波及具体装置步骤,外围就是文末的链接地址^_^

波及根本组件

python3
gprof2dot.py script
php7.*
xdebug(php extension)
graphviz(dot)
webgrind 【图形化输入,留神须要依据本身机器装置的python的地位,去更改config.php

成果

点击上图中的 Show Call Graph,且抉择你须要追踪的接口(上图下拉框中列表),即可有以下图

可选组件

openssl (次要是解决 pip3 install gprof2dot的'SSLError'问题,此文章不波及解决此问题)

如何应用装置

应用时在申请的url里增加参数?XDEBUG_PROFILE,即可生成剖析文件, 比方 xx.com?XDEBUG_PROFILE

xdebug配置,波及次要是profiler相干选项

[xdebug]zend_extension = /home/r/php7.13/lib/php/extensions/no-debug-non-zts-20151012/xdebug.soxdebug.idekey = "PHPSTORM"xdebug.default_enable = On#xdebug.remote_connect_back = 1xdebug.remote_port = 9001xdebug.remote_enable=onxdebug.remote_host = 10.2.23.200xdebug.remote_port = 9001xdebug.remote_handler = "dbgp"xdebug.mode=profile,trace,debugxdebug.remote_autostart="On"xdebug.auto_trace=1xdebug.trace_output_dir="/tmp/xdebug"xdebug.profiler_output_dir="/tmp/xdebug"xdebug.profile_output_name="script.%t-%s"xdebug.profiler_output_dir = "/home/r/php7/xdebug/profiler"#xdebug.trace_output_dir = "/home/r/www/xdebug_trace"  #xdebug.trace_output_dir = "/home/r/www/xdebug_trace"  #xdebug.trace_output_name= "%R.html"#xdebug.collect_params=2#xdebug.collect_return=1#xdebug.show_mem_delta=1#xdebug.trace_format=2xdebug.profiler_enable_trigger=1xdebug.profiler_output_name = cachegrind.out.%t.%pxdebug.profiler_enable=1xdebug.profiler_append=0xdebug.profiler_aggregare=0

webgrind 我的项目的 nginx 配置

server{   listen       80;   server_name  p.webgrind.com;   root /home/r/www/webgrind/webgrind;   index index.php;access_log /home/r/nginx/logs/webgrind.access.log;error_log /home/r/nginx/logs/webgrind.error.log;    location / {        index index.php;        try_files $uri $uri/ /index.php?$args;    }    location ~ .*\.(php|php7)?$ {        fastcgi_pass 127.0.0.1:9000;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        fastcgi_index index.php;        include fastcgi_params;        client_max_body_size 30M;        client_body_temp_path /data;    }}

centos 6*版本

下载阿里云的Centos-6.repo文件
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

从新加载yum
yum clean all
yum makecache
yum install graphviz

windows版本

windows上绝对更简略,能够先通过脚本测试xdebug收集的信息是否能用py脚本生成图

python gprof2dot.py -n 10 -f callgrind .\cacheGrind\cachegrind.out.1657783826.106186 | dot -T png -o my.png

外围文章:

https://github.com/jrfonseca/...
https://github.com/jokkedk/we...
https://github.com/jokkedk/we...

相干下载链接:

http://www.openssl.org/source...
https://www.python.org/ftp/py...

https://raw.githubusercontent...

http://slproweb.com/download/...
https://gitlab.com/api/v4/pro...

其余性能扩大工具

oneAPM
xhprof+xhGui
workerman-statistics
Blackfire
newRelic