| Java, Eclipse and Web programming Tutorials |
Version 0.6
Copyright © 2007 - 2009 Lars Vogel
17.11.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 - 0.2 | 19.10.2007 | Lars Vogel |
| Described simple test for web applications | ||
| Revision 0.3 | 05.01.2009 | Lars Vogel |
| Described profiling of standard Java applications | ||
| Revision 0.4 | 15.11.2009 | Lars Vogel |
| Started update to Eclipse 3.5 | ||
| Revision 0.5 | 16.11.2009 | Lars Vogel |
| Added filter for packages | ||
| Revision 0.6 | 17.11.2009 | Lars Vogel |
| Removed web recording due to issues | ||
Table of Contents
Eclipse Test and Performance Tools Platform (TPTP) is a Eclipse project that contains tools for performance-testing, application profiling and testing an application. http://www.eclipse.org/tptp/
TPTP allows to profile your code. This includes the profiling of Java applications, JUnit test and web applications. TPTP allow to test and trace the applicationand test several aspects of your application's behavior, including memory usage (how many objects are being created, and the the size of the objects), execution traces (how much time did the application spend in certain code), and test coverage (how much of the code was executed during the JUnit tests).
Use the Eclipse update manager to install the Eclipse TPTP tools. You find TPTP under "Testing and Performance" in the update manager. Please see Using the Eclipse Update Manager for an introduction to the update manager .
Create a Java project "de.vogella.tptp.javaproject". Create the following class for testing TPTP.
package de.vogella.tptp.javaproject;
import java.util.ArrayList;
import java.util.List;
public class Main {
private List<String> list;
public void addString(){
list = new ArrayList<String>();
for (int i = 0; i < 10000; i++) {
String string = "Hello";
list.add(string);
}
}
public void printString(){
for (String string : list) {
System.out.println(string);
}
}
public static void main(String[] args) {
Main test = new Main();
test.addString();
test.printString();
}
}
To profile a Java application, simply select the Java main class, right click and select "Profile as -> Java Application"

The first time this will open a pop-up which allows you to select for which criteria you are profiling your application for.

The latest JVMTI profiler supported by JVM version 1.5+ allows only mutually exclusive analysis types. Therefore only a single analysis type is available per each profiling session. For example you can profile for memory or for runtime but not for both.
To change later your selection please choose the following.

Switch to the perspective "Profiling and Logging" if you are asked. Here you can then see the report based on your selection.
Here you can review the result of your profile. I believe the reports are more or less self-explaining so I encourage you to review your results and identify the hotspots in your application.



TPTP allows also to profile Eclipse RCP applications. Create a Eclipse RCP application "de.vogella.tptp.rcpproject" based on the "Eclipse RCP with a view template" and profile it similar to an Java application.
See Eclipse RCP Tutorial for an introduction into Eclipse RCP development.
Thank you for practicing with this tutorial.
Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.
I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.
http://www.eclipse.org/tptp/ TPTP homepage
http://www.eclipse.org/tptp/home/documents/index.php TPTP documentation