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

环境

  • JProfiler 17.1.3(IDEA插件)
  • JProfiler 9.2(可执行软件)
  • IntelliJ IDEA 2017.2.5

下载

下载JProfiler(IDEA)插件

方式1:

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

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

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

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

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

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

方式2:

官网下载插件,手动安装

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

  • https://plugins.Jetbrains.com/plugin/253-jprofiler
一个被低估的插件:IDEA+JProfiler=性能分析神器

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

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

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

安装

安装JProfiler监控软件

官方下载地址

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

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

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

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

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

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

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

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

配置

配置IDEA运行环境

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

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

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

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

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

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

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

扩展

配置JRebel和JProfiler同时运行

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

方式1:

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

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

set CATALINA_OPTS=-agentpath:D:servicejprofiler9binwindows-x64jprofilerti.dll=port=8849,nowait,id=80,config=C:UsersAdministrator.jprofiler9config.xml %CATALINA_OPTS%

方式2:

通过Idea JRebel 启动

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

CATALINA_OPTS=-agentpath:D:servicejprofiler9binwindows-x64jprofilerti.dll=port=8849,nowait,id=81,config=C:UsersAdministrator.jprofiler9config.xml
一个被低估的插件:IDEA+JProfiler=性能分析神器

启动JRebel

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

看到控制台如下信息,说明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:UsersAdministrator.jprofiler9config.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:serviceJavajdk1.8.0_101jre
二月 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:UsersAdministrator.IntelliJIdea2017.2systemtomcatUnnamed_Service-ALL_7
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         D:servicetomcatService-tomcat-7.0.64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Drebel.base=C:UsersAdministrator.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:UsersAdministrator.IntelliJIdea2017.2configpluginsjr-ide-idealibjrebel6libjrebel64.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:UsersAdministrator.IntelliJIdea2017.2systemtomcatUnnamed_Service-ALL_7conflogging.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:servicejprofiler9binwindows-x64jprofilerti.dll=port=8849,nowait,id=80,config=C:UsersAdministrator.jprofiler9config.xml
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:servicetomcatService-tomcat-7.0.64endorsed
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:UsersAdministrator.IntelliJIdea2017.2systemtomcatUnnamed_Service-ALL_7
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:servicetomcatService-tomcat-7.0.64
二月 05, 2018 5:55:04 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=D:servicetomcatService-tomcat-7.0.64temp
二月 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:UsersAdministrator.jrebeljrebel.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

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

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

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

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

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

选择虚拟机的类型

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

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

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

选择tomcat启动脚本

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

选择端口号默认就行

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

然后一直Next,最后成功。

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

完成!

来源:blog.csdn.net/wytocsdn/

article/details/79258247

后端专属技术群

构建高质量的技术交流社群,欢迎从事编程开发、技术招聘HR进群,也欢迎大家分享自己公司的内推信息,相互帮助,一起进步!

文明发言,以交流技术职位内推行业探讨为主

广告人士勿入,切勿轻信私聊,防止被骗

一个被低估的插件:IDEA+JProfiler=性能分析神器
加我好友,拉你进群

原文始发于微信公众号(Java知音):一个被低估的插件:IDEA+JProfiler=性能分析神器

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/148972.html

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!