如何在构建日志时提高 StringBuilder 的性能,因为它会扩展容量?

huangapple 未分类评论44阅读模式
英文:

How to improve the performance of StringBuilder while constructing log cause it expands capacity?

问题

我在项目中使用Thrift作为RPC框架,它会自动生成使用StringBuilder的toString方法。但当对象太大时,通过火焰图我发现在多次扩展容量时,StringBuilder的性能开销很大。有没有什么方法可以优化这个问题?

英文:

I use thrift as a RPC framework in project which automatically generates toString method using StringBuilder. But when the object is too big, using flame graph I found StringBuilder cost a lot while expanding capacity too many times. Is there any ways I could optimize it?

huangapple
  • 本文由 发表于 2020年4月5日 20:34:08
  • 转载请务必保留本文链接:https://java.coder-hub.com/61042654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定