Tag Archives: intellij

How to use JProfiler for Performance testing

If you are a developer, some point of time you will have to use JProfiler for measuring the performance of your application. Many times, this is left to specialized performance teams or developers who know the tools well, but don’t know much about the code that they are trying to measure the performance. This approach, despite might be working, can have its flaws. Especially since performance team members are not writing the code. So as part of this past, I want to debunk few myths around this and why a developer should equally focus on a tool like JProfiler to check the performance.

What will you need

  • JProfiler (standalone or plugin in IntelliJ)
  • IntelliJ
  • A web application that you can profile

Understanding JProfiler

First JProfiler is a tool to understand what is going on inside a running JVM. Before we run the test, we should understand the basic functionality of JProfiler and how it will help us in performance improvement.

There are three aspects to JProfiler:

Time Profiling – This measures the execution paths of your application on the method level.

Memory Profiling – This provides the in-depth understand of heap usage by the application.

Thread Profiling – This analyses the thread synchronization issues.

JProfiler combines time, memory and thread profilers in a single application.

Performance Test

In this test, we will be profiling java code of the application. You can download JProfiler as a standalone tool to run or download a plugin with IntelliJ which is what I have done in my case.

Once you start IntelliJ for your web application either locally or remotely, you will see an icon on top right to start the JProfiler. If you are running the application locally, JProfiler will launch and will ask user to find the directory where JProfiler.exe is located, once you click OK, it will start the application server (from intelliJ RUN configuration).

JProfiler from IntelliJ

In Filter Settings , you can select the option Edit and it will launch another window where you can provide other application related settings. You can also run JProfiler for a remote application. For that you can provide the application’s host and port address in this application settings.

Application Settings

In my case, I am running the application locally, so I will skip these settings for right now.

Once the OK button is clicked, it will launch the tomcat webserver that I am using in this Spring based web application. I will launch my application in another browser window and do the necessary testing with application. JProfiler should profile my activity. Once you do that, we can verify CPU view for hot spots that Profiler found in our application. This will look like below:

Hot Spots

One good thing about this feature is that it shows where the application is taking more time and it is arranged in descending order. So most of the time that my code is taking in the libraries that I am using. If you expand each node, you will find in detail about each method that is getting called.

Conclusion

In this post, I showed how to use JProfiler. This was an introductory post as I have not talked about the different views that JProfiler offers for profiling the application.