Arthas常用的命令(二)--trace
trace 参数
参数名称 | 参数说明 |
---|---|
class-pattern | 类名表达式匹配 |
method-pattern | 方法名表达式匹配 |
condition-express | 条件表达式 |
-E | 开启正则表达式匹配,默认为通配符匹配 |
-n | 命令执行次数 |
#cost | 方法执行耗时 |
-m | 指定 Class 最大匹配数量,默认值为 50。 |
trace 统计方法耗时
格式:
trace 包的路径.类名 方法名
示例:
[arthas@19440]$ trace *.MathGame run
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 88 ms, listenerId: 15
`---ts=2023-06-08 21:26:27;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@1909752
`---[0.9027ms] demo.MathGame:run()
+---[9.72% 0.0877ms ] demo.MathGame:primeFactors() #24
`---[58.40% 0.5272ms ] demo.MathGame:print() #25
trace 统计最耗时的方法
格式:
trace *.类名 *
*表示任意匹配。
trace根据条件展示耗时
- 只会展示耗时大于 10ms 的调用
trace demo.MathGame run '#cost > 10'
trace 次数限制
- 可以用
-n
参数加上数字,指定捕捉结果的次数
trace demo.MathGame run -n 1
trace 多个类或者多个函数
trace 命令只会 trace 匹配到的函数里的子调用,并不会向下 trace 多层。
可以用正则匹配路径上的多个类和函数,进行多层 trace 。
trace -E com.test.ClassA|org.test.ClassB method1|method2|method3
参考资料:
分类:
其他--arthas
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了