Java Vibes..

June 22, 2009

Java Profiling Tools

Java Code Profiling is a common requirement in projects for analyzing performance bottlenecks. Although there are quite a few commercial tools available for this, but I found the following free/open-source tools extremely helpful.

Tools Overview

Tool Name Description
TPTP The Test and Performance Tools Platform (TPTP) is an eclipse based platform that provides frameworks for testing, tracing, profiling and monitoring java based programs. It provides extensive profiling tools for both standalone and distributed java applications. It includes a JVMPI monitoring agent that collects trace and profile data. And it can also Collect and analyze heap and stack information.
Using the TPTP
JIP The Java Interactive Profiler (JIP) is a high performance, low overhead profiler that is written entirely in Java. JIP gives the developer the ability to turn the profiler on and off while the VM is running. You can also filter out classes and packages as well as control the output.
Interactive Profiling

TPTP Profiling

Test and Performance Tools Platform (TPTP) is an Eclipse project and it can downloaded either as a complete Eclipse runtime or a plugin that can be installed on your current eclipse installation. The tool is tightly integrated with Eclipse, allowing profiling of applications running from within Eclipse. Thus this can not be used to profile applications running on a Unix server for e.g. Such applications cab be profiled using the JIP profiler (see below).

Here we show how to download, install and use the TPTP profiler to profile a Java application.


1.  Download Eclipse 3.4.1 or 3.4.2 (Ganymede) runtime(if you don’t already have it) and install it in c:\eclipse

2.  Download the TPTP platform runtime and trace runtime and install it on top of your eclipse platform

3.  Make sure you have JDK 5 installed on your system.

4.  Create a shortcut to Eclipse and modify the shortcut target to start Eclipse with the following options: C:\eclipse\eclipse.exe -vm “C:\jdk1.5.0_18\bin\javaw.exe” -vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M

5.  Import the application and set the classpath as required:



1. Run the JUnit through TPTP profiling:


2. Specify profile configuration:


3. Modify filters (double click on Java Profiling):


4. Start Profiling:


JIP Profiling

Java Interactive Profiler (JIP) is a pure java profiler and it gets attached to the JVM as a java agent to collect performance statistics. It is different from other java agent based profilers since it lets you control the profiling while your application is running. Most other java profilers start when your program starts and end when the JVM exits. In many cases this doesn’t give you a true measure of performance since the Just In Time compiler doesn’t compile code on the first pass. In addition, this type of profiler is not useable at all in web applications since you end up profiling the web container as well as the web application. JIP, on the other hand, allows you to turn the profiler on and off while the JVM is running.

Here we show how to download, install and use JIP to profile an application.


1. Download JIP binaries and unzip it in some folder say (c:\jip-1.1.1)

2. Copy the profiler.jar and from c:\jip-1.1.1\profile to a folder on the server (say /devel/performance)

3. Create a shell script, say and specify the JAVA_HOME as a JDK 5 folder on the server. Also set the classpath with all the jar files needed by the Junit test case that you want to profile.


1. Run the following command (through the above shell script) to start the profiler:

$JAVA_HOME/bin/java -javaagent:./profile.jar -Djip.OUTFILE=./profile.txt junit.textui.TestRunner WorkBasketPerformanceTest

You may also profile the JUnit test case as a java program if you put the following method in the test case:

public static void main(String args[]) { (WorkBasketPerformanceTest.class);

Here is the command to run the test case as a Java program:

$JAVA_HOME/bin/java -javaagent:./profile.jar -Djip.OUTFILE=./profile.txt WorkBasketPerformanceTest

2. Copy the generated profile.xml (from /devel/performance) to your local folder: c:\jip-1.1.1\client

3. Now you may view the profiler output through the following command:

c:\jdk1.5.0_18\bin\java -jar jipViewer.jar profile.xml

4. Here is a sample output:



1 Comment »

  1. You might want to check this: Much easier to use and lower-overhead than then TPTP and JIP.

    Comment by asmcoder — June 26, 2009 @ 9:47 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: