使用VisualVM進行Java應用的效能測量
Recently I am trying to find a handy tool to measure the performance of my Java application and finally I think the VisualVM provided by JDK is the ideal one. This blog is written based on JDK1.7 + Eclipse 4.3.2.
What is VisualVM
It is a tool automatically available after JDK is installed. The executable file could be found on your /bin as displayed below.
In order to measure the performance of your application, it is necessary for the application to be recognized by VisualVM first. There is a plugin named “VisualVM launcher for Eclipse” which can help us about it.
Install and configure VisualVM launcher
(1) download the zip from http:// visualvm.java.net/eclip se-launcher.html . Unzip the file and put it to the plugin folder of your Eclipse installation folder. In my laptop it looks like below. There should be a site.xml inside the unzipped folder.
(2) In Eclipse, choose menu “Help->Install New Software”, click “Local”, add locate the folder to the one you finish in step1.
Then the local downloaded plugin is successfully parsed and ready for install.
finish the installation.
(3) Restart Eclipse, then you can find a new option via the path below. Configure two paths accordingly.
For “JDK Home”, if you configure the JRE path by mistake, later when you try to measure your application, the VisualVM will fail to load with the following error message:
Now the plugin is ready to use.
Do performance measurement
(1) Select your Java project, choose context menu “Run as”->”Run configuration”, create a new Application configuration by specifying VisualVM launcher as its launcher, instead of the default Eclipse JDT launcher.
(2) For example I have a Java application which sorts an array by QuickSort algorithm written by myself and I would like to get its performance data, then I set a breakpoint on line 57, before my main logic is executed. Then launch the application in debugging mode with the application configuration created in previous step. Afterwards VisualVM will automatically be launched and successfully recognize the execution of my application. Click Profiler tab:
Current status: profiling inactive. Click CPU button:
Now profiling is activated:
(3) Go back to Eclipse and click F8 to finish execution. Once finished, VisualVM will immediately capture this event and notify you. Just click Yes to get performance result.
The result is displayed as below:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2717882/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用JDK自帶的VisualVM進行Java程式的效能分析JDKLVMJava
- 使用火焰圖進行Java應用效能分析Java
- 使用 OSProfiler 對 OpenStack 進行效能測量
- 使用 ABAP 事物碼 SAT 對從瀏覽器開啟的 SAP應用進行效能監控和測量瀏覽器
- 效能測試之JVM的故障分析工具VisualVMJVMLVM
- 使用Loadrunner進行效能測試
- 使用 Sysbench 進行 Linux 效能測試Linux
- 如何使用SAP事務碼SAT進行UI應用的效能分析UI
- 使用 Dynatrace 對 Node.js 應用的效能資料進行分析Node.js
- Android Studio 3.0 利用 Android Profiler 測量應用效能Android
- 使用 Java 進行移動應用開發的 8 個理由 - VikrantJava
- 使用Java後端對Angular應用進行Docker化 -BhargavJava後端AngularDocker
- [譯] 使用 Kotlin 協程改進應用效能Kotlin
- 使用python對oracle進行簡單效能測試PythonOracle
- web前端應用效能指標測量工具有哪些?Web前端指標
- VisualVM第一章-VisualVM的下載和使用LVM
- JMH-大廠是如何使用JMH進行Java程式碼效能測試的?必須掌握!Java
- Java 應用壓測效能問題定位經驗分享Java
- Flutter應用進行自動化測試Flutter
- 【TEST】Oracle19c使用benchmarksql進行效能測試OracleSQL
- 使用 jMeter 對 SAP Spartacus 進行併發效能測試JMeter
- 【譯】Google - 使用 webpack 進行 web 效能優化(三):監控和分析應用GoWeb優化
- 如何使用Java串列埠進行資料通訊及應用案例Java串列埠
- 基於PostgreSQL進行Java應用開發SQLJava
- 使用pprof進行效能分析
- Idea進行java應用的遠端除錯Remote debuggingIdeaJava除錯REM
- JDBC 在效能測試中的應用JDBC
- 使用應用程式(Java/Python)訪問MaxCompute Lightning進行資料開發JavaPython
- 移動應用app測試怎麼進行?APP
- 使用java+TestNG進行介面迴歸測試Java
- 效能測試進階實踐篇:10分鐘教你使用JMeter進行websocket測試!JMeterWeb
- 哪些功能需要進行效能測試?
- 使用 preloadRouteComponents 提升 Nuxt 應用的效能UX
- 效能測試應用領域
- 如何使用Nginx對Artifactory進行http應用NginxHTTP
- 使用shouldComponentUpdate進行效能優化優化
- SRE 彈效能力:使用 Envoy 對應用進行速率限制
- 一文帶你讀懂iOS應用如何使用TestFlight進行測試iOS