idea 性能分析之 Java Flight Recorder

Java Flight Recorder (JFR) 是一种监视工具,可在应用程序执行期间收集有关 Java 虚拟机中特定时刻的事件(数据片段)的信息。

以下 JDK 版本本身支持 Java Flight Recorder:

  • Oracle JDK 8-10:前提UnlockCommercialFeatures启用了VM 选项

  • Oracle JDK 11 及更高版本

  • OpenJDK 11 及更高版本

为 Oracle JDK 8 或更高版本启用 JFR

  1. 从主菜单中,选择运行 | 编辑配置并从左侧的列表中选择要使用 JFR 分析的运行配置。

  2. VM 选项字段中,添加以下行:-XX:+UnlockCommercialFeatures.

    该标志解锁了 Oracle Java SE Advanced 或 Oracle Java SE Suite 产品的商业特性。在启用它们之前,请仔细阅读JAVA SE 平台产品的 Oracle 二进制代码许可协议

  3. 应用更改并关闭对话框。如下图:

JFR configurations

There are two pre-installed configurations: Default and Profile. The Default configuration has low overhead (about 1%). That's why it works well for continuous profiling. The Profile configuration has overhead about 2% and can be used for more detailed application profiling.

These configurations cover most use cases. You can select the most suitable configuration in Settings/Preferences | Build, Execution, Deployment | Java Profiler | Java Flight Recorder.

JFR configurations

If the pre-defined configurations don't meet your needs, you can create and upload your own settings by means of Java Mission Control.

点击分析WordDao的main方法,如下图

 

 默认分析结果会dump到home目录里面

不过这时候我们查看下面的Profiler窗口已经有结果了:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

子燕若水

吹个大气球

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值