Java性能分析,火焰图分析cpu热点代码

记录一下如何用工具分析找到项目中占用cpu时间最长的代码
主要是两个工具,一个是async-profiler,另外一个是FlameGraph
可以利用git,从github仓库中,下载下来。

git clone https://github.com/jvm-profiling-tools/async-profilergit clone https://github.com/brendangregg/FlameGraph

下载之后,进入对应的目录,给执行权限。
cd async-profiler chmod +x *.shcd FlameGraph chmod +x *.pl

对于,async-profile需要编译一下
cd async-profiler make

然后,找到对应的java程序的进程,比如有进程23987
jps -l

【Java性能分析,火焰图分析cpu热点代码】进入async-profiler目录,采集数据,进行监控
./profiler.sh -d 20 -o collapsed -f /tmp/profile.log 23987

进入FlameGraph目录,输出到svg
./flamegraph.pl --colors=java /tmp/profile.logt > /tmp/profile.svg

文章来源:https://blog.csdn.net/flybridy/article/details/81947570

    推荐阅读