一个被低估的插件:IDEA+JProfiler=性能分析神器

点击上方“Java基基”,选择“设为星标”

做积极的人,而不是积极废人!

每天 14:00 更新文章,每天掉亿点点头发...

源码精品专栏

 

来源:blog.csdn.net/wytocsdn/

article/details/79258247


环境

  • JProfiler 17.1.3(IDEA插件)

  • JProfiler 9.2(可执行软件)

  • IntelliJ IDEA 2017.2.5

基于 Spring Boot + MyBatis Plus + Vue & Element 实现的后台管理系统 + 用户小程序,支持 RBAC 动态权限、多租户、数据权限、工作流、三方登录、支付、短信、商城等功能

  • 项目地址:https://github.com/YunaiV/ruoyi-vue-pro

  • 视频教程:https://doc.iocoder.cn/video/

下载

下载JProfiler(IDEA)插件

方式1:

在IDEA上直接下载Settings–plugins–Browse repositories

71ed6585896ae70b5ffd5d76dc5fff23.png

搜索JProfiler 点击 install 按钮安装,然后从启IDEA工具

aa3492031b6698812196969927543b2b.png

看到如下图片则说明安装完成

026198142861618464b9f6ba3c441d05.jpeg

方式2:

官网下载插件,手动安装

在首页向下翻,中部位置能看到JProfiler最新版本,包括历史版本下载链接,本教程中我们选择17.1.3版本。点击DOWNLOAD进行下载。

  • https://plugins.jetbrains.com/plugin/253-jprofiler

ad59da499560edee97c38ede7f30fd7e.png

把从下载的压缩包解压出来的JProfiler文件夹,copy到IDEA自定义插件目录,默认路径:C:\Users\Administrator.IntelliJIdea2017.2\config\plugins

从启IDEA看到如下图标则安装成功:

900652d88cb12feeebe81eff9aaabafb.jpeg

基于 Spring Cloud Alibaba + Gateway + Nacos + RocketMQ + Vue & Element 实现的后台管理系统 + 用户小程序,支持 RBAC 动态权限、多租户、数据权限、工作流、三方登录、支付、短信、商城等功能

  • 项目地址:https://github.com/YunaiV/yudao-cloud

  • 视频教程:https://doc.iocoder.cn/video/

安装

安装JProfiler监控软件

官方下载地址

  • https://www.ej-technologies.com/download/jprofiler/version_92

右上角可以选择要下载版本

7711b0b4e3ddfb5fe4594adb54953c4c.jpeg

注:本教程选择的版本是9.2

下载完双击运行,选择自定义目录安装,点击Next

740956e2ecee1a23f1ca04fb3b634e9c.png

选择安装路径,建议选择一个文件名中没有中文,没有空格的路径因为如果改手动启动时,空格识别不了。然后一直点Next

017c9da0283758d5e81026a07227ef98.png

配置

配置IDEA运行环境

Settings–Tools–JProflier–JProflier executable选择JProfile安装可执行文件。(如果系统只装了一个版本,启动IDEA时会默认选择)保存

2b0f7a86169dc2c306eef7ee153de389.png

选择你要分析的项目,点击JProfiler图标启动。

8523ea888ad8cd39a2f9690b45d0cb2e.png

启动完成会自动弹出JProfiler窗口,在里面就可以监控自己的代码性能了。

1e69f883630c06bca092aa78cff6e23e.png

至此IDEA中配置JProfiler做性能分析就完成了!

扩展

配置JRebel和JProfiler同时运行

有些人在IDEA中配置了JRebel热部署,要想JRebel和JProfiler同时运行,就要改手动管理JProfiler session了。

方式1:

通过点击tomcat的启动脚本启动

在要分析的tomcat启动脚本catalina.bat中增加一行。

set CATALINA_OPTS=-agentpath:D:\service\jprofiler9\bin\windows-x64\jprofilerti.dll=port=8849,nowait,id=80,config=C:\Users\Administrator\.jprofiler9\config.xml %CATALINA_OPTS%

方式2:

通过Idea JRebel 启动

IDEA Run/Debug Configurations窗口JRebel Debug中配置Environment Variables属性。

CATALINA_OPTS=-agentpath:D:\service\jprofiler9\bin\windows-x64\jprofilerti.dll\=port\=8849,nowait,id\=81,config\=C:\Users\Administrator\.jprofiler9\config.xml
5a4404845ee8708e2ee9be2d61de1404.png

启动JRebel

165ec920ad794c365dd77cc33c22655c.png

看到控制台如下信息,说明JRebel和JProfiler都启动了。

JProfiler> Protocol version 55
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> Don't wait for frontend to connect.
JProfiler> 64-bit library
JProfiler> Using config file C:\Users\Administrator\.jprofiler9\config.xml (id: 80)
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
2018-02-05 17:55:02 JRebel:
2018-02-05 17:55:02 JRebel: A newer version '7.1.5' is available for download
2018-02-05 17:55:02 JRebel: from http://zeroturnaround.com/software/jrebel/download/
2018-02-05 17:55:02 JRebel:
Connected to the target VM, address: '127.0.0.1:61805', transport: 'socket'
JProfiler> VM initialized
2018-02-05 17:55:02 JRebel: Contacting myJRebel server ..
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/7.0.64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Aug 19 2015 17:18:06 UTC
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         7.0.64.0
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 7
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            6.1
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             D:\service\Java\jdk1.8.0_101\jre
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_101-b13
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         C:\Users\Administrator\.IntelliJIdea2017.2\system\tomcat\Unnamed_Service-ALL_7
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         D:\service\tomcat\Service-tomcat-7.0.64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.base=C:\Users\Administrator\.jrebel
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.env.ide.plugin.version=7.1.4
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.env.ide.version=2017.2.5
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.env.ide.product=IU
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.env.ide=intellij
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.notification.url=http://localhost:17434
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentpath:C:\Users\Administrator\.IntelliJIdea2017.2\config\plugins\jr-ide-idea\lib\jrebel6\lib\jrebel64.dll
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:61805,suspend=y,server=n
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote=
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.port=1099
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.ssl=false
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.rmi.server.hostname=127.0.0.1
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator\.IntelliJIdea2017.2\system\tomcat\Unnamed_Service-ALL_7\conf\logging.properties
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentpath:D:\service\jprofiler9\bin\windows-x64\jprofilerti.dll=port=8849,nowait,id=80,config=C:\Users\Administrator\.jprofiler9\config.xml
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\service\tomcat\Service-tomcat-7.0.64\endorsed
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:\Users\Administrator\.IntelliJIdea2017.2\system\tomcat\Unnamed_Service-ALL_7
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\service\tomcat\Service-tomcat-7.0.64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=D:\service\tomcat\Service-tomcat-7.0.64\temp
二月 05, 2018 5:55:04 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
二月 05, 2018 5:55:04 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2018-02-05 17:55:06 JRebel:  Starting logging to file: C:\Users\Administrator\.jrebel\jrebel.log
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:  #############################################################
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:  JRebel Agent 7.1.4 (201712200830)
2018-02-05 17:55:06 JRebel:  (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:  Over the last 16 days JRebel prevented
2018-02-05 17:55:06 JRebel:  at least 117 redeploys/restarts saving you about 0 hours.
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:  Licensed to wenyuan hou (using myJRebel).
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:
2018-02-05 17:55:06 JRebel:  #############################################################
2018-02-05 17:55:06 JRebel:

点击jprofiler.exe

执行菜单Session–Integr ation Wizards–New Server Integration

66311b9802cc7a2a64277a49c6d7f957.jpeg

选择tomcat容器版本(7.X)

da6697af324deefd15dba318cd7aafd9.jpeg

选择是本地测试还是远程测试(本处选本地)

fc751fefebd673f4e87db0799ccea163.png

选择虚拟机的类型

cd692254b1a0a61dea5b2b9c7ee9e6e4.png

选择Web容器是否和Jprofiler一起运行(我们使用JRebel启动,所以选择第二个)

9e3dc2f13da6ef32e5df1d882d281e1e.png

选择tomcat启动脚本

1bcb6283bcf7df40688555dce6d17ad7.png

选择端口号默认就行

478797609cd50b329c9e642e3b764aa7.png

然后一直Next,最后成功。

dc7f3a7ab8fcc02d9d3c24074efab2ab.png

完成!



欢迎加入我的知识星球,一起探讨架构,交流源码。加入方式,长按下方二维码噢

cf4bf6f607c5147c915a77d24a7ac440.png

已在知识星球更新源码解析如下:

48c8c40b32175295009aaebbfdad6aaa.jpeg

dd7a832cd324fdc88c489946e469bf54.jpeg

5ed493087ffb0843e6ddda035074812a.jpeg

6fab1caa540e78800188c656801921ed.jpeg

最近更新《芋道 SpringBoot 2.X 入门》系列,已经 101 余篇,覆盖了 MyBatis、Redis、MongoDB、ES、分库分表、读写分离、SpringMVC、Webflux、权限、WebSocket、Dubbo、RabbitMQ、RocketMQ、Kafka、性能测试等等内容。

提供近 3W 行代码的 SpringBoot 示例,以及超 6W 行代码的电商微服务项目。

获取方式:点“在看”,关注公众号并回复 666 领取,更多内容陆续奉上。

文章有帮助的话,在看,转发吧。
谢谢支持哟 (*^__^*)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值