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

点击关注公众号,Java干货及时送达👇

环境

  • JProfiler 17.1.3(IDEA插件)

  • JProfiler 9.2(可执行软件)

  • IntelliJ IDEA 2017.2.5

下载

下载JProfiler(IDEA)插件

方式1:

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

d89037b743cc178f58c80129d15cf269.png

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

fc2379695959ff296b18078edcb29895.png

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

f040896808d578bd2eb1bbed536d6c19.png

方式2:

官网下载插件,手动安装

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

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

9acd4ee09b88ddb38755b93fda20101e.png

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

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

4ae1e5aab66a5fadd979bb81709acddc.png

安装

安装JProfiler监控软件

官方下载地址

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

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

60b2cc7b8ab927454fb9800ed8c004ae.png

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

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

363f6fe11b21646e19e280a1004c4b40.png

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

fc82e69e6c29702243e1dfbfbb5def0c.png

配置

配置IDEA运行环境

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

60fc7dd1834235200bd744191f7918e4.png

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

452e2cb1cf1170c10b9f17824e9a4b5e.png

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

f7ea9189736ac27f328cd38353adb1f6.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
eccd4bf165b73f1e6b595300f5815fb4.png

启动JRebel

ab78be4b31f16544b8deeefd9b4ff791.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

b8f9b12e14327dd5b734f99aae57e9ec.png

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

df103aeca8d02390a5c68393954b206c.png

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

b343ae7876ea569df5c387e9013ebb54.png

选择虚拟机的类型

39c82885e02191088a7b9dd90ac7ddd9.png

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

2dbae461708f126da2a6d41fe5335a21.png

选择tomcat启动脚本

20e1be1939cf8c886e4e4e8bd67dcbb5.png

选择端口号默认就行

3163bc691a5e83a1952c084f13040e37.png

然后一直Next,最后成功。

d3905efe3abf791ece07097afa518962.png

完成!

来源:blog.csdn.net/wytocsdn/

article/details/79258247

 
 
 
 
 
 
 
 
 
 
 
 

f5b094f376036a1aa1004b7eda486340.gif

 
 

23 届校招技术岗薪资汇总

面试官问我 ,try catch 应该在 for 循环里面还是外面?

再见了 shiro

一行 log 日志,结果引发了 P1 的线上事故

只会用 xxl-job?更强大的新一代分布式任务调度框架来了!

美团又一开源力作,收下这一整套日志体系吧!

 
 
 
 
 
 
 
 
最近面试BAT,整理一份面试资料《Java面试BAT通关手册》,覆盖了Java核心技术、JVM、Java并发、SSM、微服务、数据库、数据结构等等。
获取方式:点“在看”,关注公众号并回复 666 领取,更多内容陆续奉上。

明天见(。・ω・。)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值