php 函数追踪扩展 phptrace
php
函数追踪扩展 phptrace
介绍#
phptrace
是一个低开销的用于跟踪、分析 php
运行情况的工具。
它可以跟踪 php
在运行时的函数调用、请求信息、执行流程、并且提供有过滤器、统计信息、当前状态等实用功能。
在任何环境下,它都能很好的定位阻塞的问题以及在高负载下进行 denbug
。
官方源码:https://github.com/Qihoo360/phptrace。
安装#
pecl
方式安装#
$ pecl install trace
源码方式安装#
$ wget https://pecl.php.net/get/trace-1.0.0.tgz # 下载源码
$ tar -xf trace-1.0.0.tgz # 解压文件
$ cd trace-1.0.0/extension # 进入扩展目录
源码编译#
$ whereis php-config # 找到 php-config 的路径
$ phpize
$ ./configure --with-php-config=/usr/bin/php-config # 这里的 --with-php-config 是上一步找到的路径
$ make # 编辑
$ make test # 编译测试
$ make cli # 命令行工具
$ make install-all # 安装 php 扩展,命令行工具到 php 目录
修改 php.ini
#
在 php.ini
配置文件中增加以下配置信息。
[phptrace]
extension=trace.so
phptrace.enabled=1
注:修改 php.ini
后,需要手动重启 php-fpm
检查是否生效#
root@639ca1f15214:~# php -m | grep trace
trace
实际测试#
root@639ca1f15214:/var/www# php -r 'for ($i = 0; $i < 20; $i++) { sleep(5); }' &
[1] 361
root@639ca1f15214:/var/www# phptrace -p $!
process attached
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.001s 5.001s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.000s 5.000s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.000s 5.000s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 4.966s 4.966s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.000s 5.000s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.002s 5.002s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.001s 5.001s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.002s 5.002s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.001s 5.001s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 4.966s 4.966s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.000s 5.000s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.003s 5.003s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.000s 5.000s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.001s 5.001s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 5.001s 5.001s
[pid 361] > sleep(5) called at [Command line code:1]
[pid 361] < sleep(5) = 0 called at [Command line code:1] ~ 4.967s 4.967s
[pid 361]> swoole_call_user_shutdown_begin() called at [(null):0]
[pid 361]< swoole_call_user_shutdown_begin() = true called at [(null):0] ~ 0.000s -79.912s
[pid 361]< cli php for ($i = 0; $i < 20; $i++) { sleep(5); }
process detached
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
2017-04-20 javascript数组对象