Debug tips

1 add log in third party code

you can create the same class with same package in your source code, then copy it's source to your class, and add log as you like, then compile it and run it, Tomcat will first load your modified class rather than the origin class which is in third party jar file.

2 run the suspicious code multi times to enlarge the different

sometime, the same statement run in one environment is less slower than run in another environment. we can run them in debug environment, but hardly compare them manually especially in debug environment. And no JProfile help, then we can using a For loop to run the statement multi times, e.g. 1000 times, then if in one environment it cost 1.5s, other cost 10s, it's easy for feel the difference.

Another reason for run the suspicious code multi times is to find the sub statement which cause downgrade.

e.g. now we know method A consume 1ms in one environment, and 10ms in other environment. And A contains statement A1-A5, we need deep into these A1-A5 to check which one cause downgrade again. then we can first try run A1 100 times in two environment, other code are same, then run A2 100 times and so on to find is there huge diffierence in two environment, for example, if we run A3 100 times and other code are same, then one environment is 70ms and 1000ms in another one. we can think A3 cause downgrade and deep into A3 again.

there are some limitation in this way: the method must be 1. can be run many time, 2. no side effect after running many times, 3. every time running consume same time, running same logic in the method.

Solving problem need try different ways and sometimes need some lucky, don't give up too early!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值