Eclipse的TPTP使用方法

 

EclipseTPTP 工具 使用 方法:
1.        TPTP是什么:
TPTP是Eclipse的一个顶级工程(Top-Level Project),TPTP项目封装了一大堆公共的操作接口与 数据,甚至一个远程执行环境,以供其它的TPTP工具使用。另外,它还提供了扩展点以方便进行定制编码。实际上就是一个依托于Eclipse的 JAVA的Profile与分析 工具,还提供了整合SWT GUI的Record与Replay功能(另外的文章中进行介绍)。

2.下载要安装的各种plugin。

以TPTP4.1为例
   a.解决安装信赖条件:
     Eclipse SDK 3.1.0
     JDK 1.4
     EMF SDK 2.1.0
     XSD 2.1.0

    b.Agent Controller安装
      下载
       将下载完的安装包解压到想安装的目录。
       将<unzip directory>\bin加到 系统PATH环境变量中,不能有双引号。
      执行<unzip directory>\bin下的SetConfig.bat生成基本 配置环境。
      执行RAServer.exe,运行守护进程。

  c.安装TPTP,此处 选择手动安装。
     下载TPTP4.1
      解压到eclipse\plugins下。

完成安装。


测试
新建一个工程( Java Project)
将下列类导入到工程中:
package com.yadong.testtptp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CarModel { /* Required car parts: 1 Engine, 4 wheels, and 2 doors */
	public Engine engine = new Engine();

	public Wheel[] wheel = new Wheel[4];

	public Door left = new Door(), right = new Door();

	public CarModel() {
		for (int i = 0; i < 4; i++)
			wheel = new Wheel();
	} /* Launcher */

	public static void main(String[] args) throws IOException {
		final String LINE_SEPARATOR = System.getProperty("line.separator");
		final int BORDER_CHAR_LENGTH = 40;
		final int UNREF_OBJ_CREATED = 10;
		StringBuffer menu = new StringBuffer();
		CarModel car = new CarModel(); /* Create the menu */
		for (int i = 0; i < BORDER_CHAR_LENGTH; i++)
			menu.append('-');
		menu.append(LINE_SEPARATOR).append("   (1) Simulate car usage");
		menu.append(LINE_SEPARATOR)
				.append("   (2) Create unreferenced objects");
		menu.append(LINE_SEPARATOR).append("   (q) Quit");
		menu.append(LINE_SEPARATOR);
		for (int i = 0; i < BORDER_CHAR_LENGTH; i++)
			menu.append('-'); /* Display the menu */
		System.out.println("CarModel started" + LINE_SEPARATOR + "Menu:");
		System.out.println(menu.toString());
		System.out.println("Choose an option:");
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String input = in.readLine().trim(); /*
												 * Accept input for the desired
												 * option
												 */
		while (!input.equalsIgnoreCase("q")) { /* Check for invalid entry */
			if (input == null || input.length() != 1
					|| !Character.isDigit(input.charAt(0))) {
				System.err.println("Wrong option");
				input = in.readLine().trim();
				continue;
			}
			switch (Integer.valueOf(input).intValue()) {
			case 1:
				simulateCarUsage(car);
				break;
			case 2:
				for (int i = 0; i < UNREF_OBJ_CREATED; i++)
					new CarModel();
				System.out.println(UNREF_OBJ_CREATED
						+ " unreferenced objects of CarModel has been created");
				break;
			default:
				System.err.println("Wrong option");
			}
			input = in.readLine().trim();
		}
	} /* Simulates car usage */

	public static void simulateCarUsage(CarModel car) {
		car.left.window.rollup();
		car.engine.start();
		car.engine.rev();
		car.wheel[0].align();
		car.engine.stop();
	}
}/* Inner classes used to model car parts */

class Engine {
	public void start() {
		System.out.println("Start the car.");
	}

	public void rev() {
		System.out.println("Rev the engine.");
	}

	public void stop() {
		System.out.println("Car stopped.");
	}
}

class Wheel {
	public void align() {
		System.out.println("Tires aligned.");
	}
}

class Window {
	public void rollup() {
		System.out.println("Rollup the window.");
	}

	public void rolldown() {
		System.out.println("Rolldown the window.");
	}
}

class Door {
	public Window window = new Window();

	public void open() {
		System.out.println("Open()");
	}

	public void close() {
		System.out.println("Close()");
	}
}
 
右键点击CarModel.java,这时会在弹出菜单中显示出Profile As ->Java Application
运行.
同时切换视图到”Profiling and logging”,这样就可以得到正在运行中 程序的Profile
在这个视图中如果设置得当的话可以查看到如下结果:

1.        Coverage
2.        Execution flow
3.        Memory
4.        Object Reference
5.        UML2 object/class/Thread Interaction


下载地址:
  Eclipse SDK 3.1.0(Win32):   www.eclipse.com/downloads/index.php
JDK 1.4(Win32):    java.sun.com
EMF SDK 2.1.0(Win32): www.eclipse.com/downloads/index.php
XSD 2.1.0(Win32):http://download.eclipse.org/tools/emf/downloads/drops/2.1.0/R200507070200/xsd-SDK-2.1.0.zip:TPTP(Win32)
http://download.eclipse.org/tptp/4.1.0/TPTP-4.1.0-200511150100/tptp.runtime-TPTP-4.1.0-200511150100.zip
Agent Controller(Win32): http://download.eclipse.org/tptp/4.1.0/TPTP-4.1.0-200511150100/tptpdc.win_ia32-TPTP-4.1.0-200511150100.zip
<!--++ plugin_code qcomic begin--><!--++ plugin_code qcomic end-->

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值