| Software Requirements: - Windows OS => WinXP, WinVista, Win7 - Eclipse v3.5 - JProfiler v5 - YourKit v8 |
Objective
A profiler is a very powerful tool to help pinpoint performance and memory issues. It offers a variety of ways to which a developer can help track down classes that lead to dismal performance, inefficiency and memory leak issues. This includes taking and comparing snapshot at certain point in time, watching how CPU time and memory is consumed in realtime in a visual chart and marking interested classes for analysis.
There are many profilers in the markets , both open-source (eg VisualVM that bundled with Java SDK) and commerical offerings. However, this document will show the steps to configure two of the best commerical Java profilers in the market, YourKit and JProfiler, to profile GWT client application in Eclipse in the Windows environment.
Even though both profilers are just as effective and powerful, both use different approach to profile the application.
Still, the following steps will work with any IDE (eg Intellij ) since it is just a matter of adding adding additional profiler’s agent as argument to the JVM. All IDEs allow argument to be passed to the JVM that run the project application.
Yourkit and JProfiler offer a 15 and 10 days evaluation trial respectively.
JProfiler profiling GWT Web client app (FigA)
Yourkit profiling GWT Web client app (FigB)
Profiling GWT client Application
Profiling a HTML web client application is considered a tedious process. Despite having tools like Firebug to assist development, it may not be sufficient as these tools are not designed for robust software development, lacking sufficent important tools and conveniences to help analyze performance and memory issues at the code level. Besides, profiling JavaScript for memory leaks manually through analyzing DOM is a near impossible task consider that developers have to manually explore the DOM tree structure in a unintuitive manner.
Traditionally a Java profiler is used to profile Java application (eg desktop and server). GWT takes a unique approach of cross-compiling Java code into JavaScript to build complex AJAX web client application. Even though Java and JavaScript share a different language and behaviour characteristics, still the notion of resolving memory leak through best practices applies.
Profiling JavaScript for performance and memory leak can be somewhat difficult if not “mission impossible”
http://googlewebtoolkit.blogspot.com/2008/11/profiling-gwt-application-performance.html
Configuring JProfiler
As of current, the Eclipse plug-in for JProfiler does not explicitly support GWT. However, through the use of Remote Session, the same result can be achieved.
For more information on setting up remote profiling,
http://resources.ej-technologies.com/jprofiler/help/doc/indexRedirect.html?http&&&resources.ej-technologies.com/jprofiler/help/doc/helptopics/config/remoteProfiling.html
There are essentially two steps after installing JProfiler.
1) Setup JProfiler GUI to communicate with the agent.
2) Prepare GWT Project Configuration to use JProfiler through agent
1) Setup JProfiler GUI to communicate with the agent.
Go to Session => Integration Wizards => New Remote Integration
Just accept those default options, and choose the desired JVM. The final screen will show the summary.
The wizard help to produce the necessary information that will be added into IDE’s project configuration.
Remember to add those PATH since it need to refer to those JProfiler DLL libraries.
The following line will be added to JVM argument. The JVM will be used to run the GWT system.
-agentlib:jprofilerti=port=8849 "-Xbootclasspath/a:C:\devsys\java\app\jprofiler\bin\agent.jar"
You can rename the session by [Session] => [Session Settings] so next time you can identify the session. Each session will automatically be saved for subsequent use.
2) Prepare GWT Project Configuration to use JProfiler through agent
To add support for profiling, simply add the above JVM line to the <VM arguments> in Argument tab of Run Configuration as shown below.
The final step is just to run the configuration as per normal, and also ensure that Session is listening for activity. Refer to (FigA) image.
The video will also show the whole process of configuring JProfiler and GWT project in Eclipse.
Configuring Yourkit
As of current, the Eclipse plug-in for Yourkit does not explicitly support GWT. However, through the use of Remote Profiling, the same result can be achieved.
For more information on setting up remote profiling,
http://www.yourkit.com/docs/80/help/agent.jsp
There are essentially two steps after installing YourKit.
1) Prepare GWT Project Configuration to use Yourkit through agent
2) Setup Yourkit GUI to communicate with the agent.
1) Prepare GWT Project Configuration to use Yourkit through agent
There are other way to enter the agent path but the convenient way is to specific absolute path.
The following line will be added to JVM argument. The JVM will be used to run the GWT system.
-agentpath:C:\devsys\java\app\YourKit\bin\win32\yjpagent.dll
The final step is just to run the configuration as per normal, and also ensure and then startup Yourkit.
2) Setup Yourkit GUI to communicate with the agent.
Upon sensing the agent running, Yourkit will automatically show the active session in the main screen. Simply click on that session will bring up analysis screen (FigB).
YourKit works by taking snapshot at various time for analysis and comparison
The video will also show the whole process of configuring Yourkit and GWT project in Eclipse.
Video
Watch the video because it says it all…


