性能分析工具-火焰图
2021-03-07性能分析工具-火焰图
-
采用 https://github.com/jvm-profiling-tools/async-profiler 进行性能分析
- 实现步骤:
public class CpuAsyncProfilerTest { public static void main(String[] args) throws InterruptedException { while (true) { CpuAsyncTask cpuAsyncTask = new CpuAsyncTask(); cpuAsyncTask.run(); } } public static void aTest() throws InterruptedException { Thread.sleep(10); bTest(); cTest(); } public static void bTest() throws InterruptedException { Thread.sleep(10); cTest(); } public static void cTest() throws InterruptedException { Thread.sleep(10); } } class CpuAsyncTask implements Runnable { @Override public void run() { try { while (true) { aTest(); } } catch (InterruptedException e) { e.printStackTrace(); } } }
- jps 找到程序的运行pid
- 生产火焰图命令
./profiler.sh -d 30 -f flamegraph.svg 43619
- 资料