Java, Eclipse and Web programming Tutorials
Follow me on twitter About Lars Vogel

Eclipse Test and Performance Tools Platform (TPTP) - Tutorial

Lars Vogel

Version 0.6

17.11.2009

Revision History
Revision 0.1 - 0.219.10.2007Lars Vogel
Described simple test for web applications
Revision 0.305.01.2009Lars Vogel
Described profiling of standard Java applications
Revision 0.415.11.2009Lars Vogel
Started update to Eclipse 3.5
Revision 0.516.11.2009Lars Vogel
Added filter for packages
Revision 0.617.11.2009Lars Vogel
Removed web recording due to issues

Eclipse TPTP

This article describes how to use the Eclipse Test and Performance Tools Platform (TPTP) for profiling your Java or your Eclipse RCP application.

This article assume that you have already basic Eclipse knowledge.


Table of Contents

1. Overview
2. Installation
3. Profiling Java applications
4. Profiling Eclipse RCP applications
5. Thank you
6. Questions and Discussion
7. Links and Literature
7.1. Eclipse TPTP Resources
7.2. Other Resources

1. Overview

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).

2. Installation

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 .

3. Profiling Java applications

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.

Tip

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.

Tip

You can also specify a filter for the packages you are interested in.

4. Profiling Eclipse RCP applications

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.

5. Thank you

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.

6. Questions and Discussion

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.

7. Links and Literature

7.1. Eclipse TPTP Resources

http://www.eclipse.org/tptp/ TPTP homepage

http://www.eclipse.org/tptp/home/documents/index.php TPTP documentation