Updated performance test suite
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
index a3cdafb..6a37c00 100644
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
+++ b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
@@ -1,17 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2000, 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
  * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
  * 
  * Contributors: 
  * IBM - Initial API and implementation
  **********************************************************************/
 package org.eclipse.core.tests.harness;
 
-import java.io.File;
-
 import junit.framework.TestResult;
 
 /**
@@ -45,19 +43,15 @@
  * of a logging test result, all log events are written to the standard output.
  */
 public abstract class CorePerformanceTest extends EclipseWorkspaceTest {
-	public static String fLogFile;
-
-	protected LoggingPerformanceTestResult fLogger = null;
-	protected PerformanceTestResult fResult = null;
-	protected File fTempDir;
-	protected File fDir;
-
 	protected long benchStart;
-public CorePerformanceTest() {
-}
-public CorePerformanceTest(String name) {
-	super(name);
-}
+	protected LoggingPerformanceTestResult logger = null;
+	protected PerformanceTestResult result = null;
+
+	public CorePerformanceTest() {
+	}
+	public CorePerformanceTest(String name) {
+		super(name);
+	}
 	protected PerformanceTestResult defaultTest() {
 		return new PerformanceTestResult();
 	}
@@ -65,8 +59,8 @@
 	 * Logs or writes string to console.
 	 */
 	public void perfLog(String s) {
-		if (fLogger != null) {
-			fLogger.log(s);
+		if (logger != null) {
+			logger.log(s);
 		} else {
 			System.out.println(s);
 		}
@@ -88,46 +82,46 @@
 	 * for running a test case.
 	 */
 	public void run(PerformanceTestResult test) {
-		fResult = test;
+		result = test;
 
 		if (test instanceof LoggingPerformanceTestResult) {
-			fLogger = (LoggingPerformanceTestResult)test;
+			logger = (LoggingPerformanceTestResult) test;
 		}
 
 		super.run(test);
 	}
-protected void startBench() {
-	for (int i = 0; i < 20; ++i) {
-		System.gc();
+	protected void startBench() {
+		for (int i = 0; i < 20; ++i) {
+			System.gc();
+		}
+		benchStart = System.currentTimeMillis();
 	}
-	benchStart = System.currentTimeMillis();
-}
-/**
- * Tell the result to start a timer with the given name.
- * If no timer exists with that name, result creates a new timer
- * and starts it running.
- */ 
-protected void startTimer(String timerName) {
-	fResult.startTimer(timerName);
-}
-protected void stopBench(String benchName, int numOperations) {
-	long duration = System.currentTimeMillis() - benchStart;
-	double perOp = (double) duration / (double) numOperations;
+	/**
+	 * Tell the result to start a timer with the given name.
+	 * If no timer exists with that name, result creates a new timer
+	 * and starts it running.
+	 */
+	protected void startTimer(String timerName) {
+		result.startTimer(timerName);
+	}
+	protected void stopBench(String benchName, int numOperations) {
+		long duration = System.currentTimeMillis() - benchStart;
+		double perOp = (double) duration / (double) numOperations;
 
-	String opString;
-	if (perOp > 100.0) {
-		opString = "(" + perOp + "ms per operation)";
-	} else {
-		//Note us == microseconds
-		opString = "(" + (perOp * 1000.0) + "us per operation)";
+		String opString;
+		if (perOp > 100.0) {
+			opString = "(" + perOp + "ms per operation)";
+		} else {
+			//Note us == microseconds
+			opString = "(" + (perOp * 1000.0) + "us per operation)";
+		}
+
+		System.out.println(benchName + " took " + duration + "ms " + opString);
 	}
-		
-	System.out.println(benchName + " took " + duration + "ms " + opString);
-}
-/**
- * Tell the result to stop the timer with the given name.
- */ 
-protected void stopTimer(String timerName) {
-	fResult.stopTimer(timerName);
-}
-}
+	/**
+	 * Tell the result to stop the timer with the given name.
+	 */
+	protected void stopTimer(String timerName) {
+		result.stopTimer(timerName);
+	}
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
index 6b2eb37..301b091 100644
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
+++ b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
@@ -1,9 +1,9 @@
 /**********************************************************************
- * Copyright (c) 2000, 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
  * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
  * 
  * Contributors: 
  * IBM - Initial API and implementation
@@ -12,6 +12,7 @@
 
 import java.io.*;
 import java.util.Enumeration;
+import java.util.Iterator;
 
 import junit.framework.TestFailure;
 /**
@@ -20,58 +21,80 @@
  * of the standard output.
  */
 public class LoggingPerformanceTestResult extends PerformanceTestResult {
-	PrintWriter fLog;
-/**
- * LoggingPerformanceTestResult constructor comment.
- */
-public LoggingPerformanceTestResult(File logFile) {
-	super();
-	try {
-		fLog = new PrintWriter(new FileOutputStream(logFile));
-		printHTMLHeader(fLog);
-	} catch (IOException e) {
-		System.out.println("Unable to open log output file: " + logFile);
-		fLog = new PrintWriter(System.out);
+	private static PrintWriter createWriter(File logFile) {
+		try {
+			PrintWriter writer = new PrintWriter(new FileOutputStream(logFile), true);
+			return writer;
+		} catch (IOException e) {
+			System.out.println("Unable to open log output file: " + logFile);
+			return new PrintWriter(System.out, true);
+		}
 	}
-}
+	public LoggingPerformanceTestResult(File logFile) {
+		super(createWriter(logFile));
+		printHTMLHeader(output);
+	}
 	/**
 	 * Logs the given string in the test log file
 	 */
 	public synchronized void log(String s) {
-		fLog.println(s);
+		output.println(s);
 	}
 	/**
 	 * Prints the test result
 	 */
 	public synchronized void print() {
-		stopTimers();
-		printHeader(fLog);
-		printTimings(fLog);
-		printErrors(fLog);
-		printHTMLTrailer(fLog);
-	}
-/**
- * Prints the errors to the standard output
- */
-protected void printErrors(PrintWriter out) {
-	out.println("<h3>Error summary</h3>");
-	int count = errorCount();
-	if (count != 0) {
-		if (count == 1)
-			out.println("There was " + count + " error:<p>");
-		else
-			out.println("There were " + count + " errors:<p>");
-		int i = 1;
-		for (Enumeration e = errors(); e.hasMoreElements(); i++) {
-			TestFailure failure = (TestFailure) e.nextElement();
-			out.println(i + ") " + failure.failedTest() + "<p>");
-			failure.thrownException().printStackTrace();
-			out.println("<p>");
+		try {
+			super.print();
+			printHTMLTrailer(output);
+		} finally {
+			output.flush();
+			output.close();
 		}
-	} else {
-		out.println("No errors reported.");
 	}
-}
+	/**
+	 * Prints the errors to the standard output
+	 */
+	protected void printErrors(PrintWriter out) {
+		out.println("<h3>Error summary</h3>");
+		int count = errorCount();
+		if (count != 0) {
+			if (count == 1)
+				out.println("There was " + count + " error:<p>");
+			else
+				out.println("There were " + count + " errors:<p>");
+			int i = 1;
+			for (Enumeration e = errors(); e.hasMoreElements(); i++) {
+				TestFailure failure = (TestFailure) e.nextElement();
+				out.println(i + ") " + failure.failedTest() + "<p>");
+				failure.thrownException().printStackTrace(out);
+				out.println("<p>");
+			}
+		} else {
+			out.println("No errors reported.");
+		}
+	} /**
+	 * Prints the failures to the output
+	 */
+	protected void printFailures(PrintWriter out) {
+		out.println("<h3>Failure summary</h3>");
+		int count = failureCount();
+		if (count != 0) {
+			if (count == 1)
+				out.println("There was " + count + " failure:<p>");
+			else
+				out.println("There were " + count + " failures:<p>");
+			int i = 1;
+			for (Enumeration e = failures(); e.hasMoreElements(); i++) {
+				TestFailure failure = (TestFailure) e.nextElement();
+				out.println(i + ") " + failure.failedTest() + "<p>");
+				failure.thrownException().printStackTrace(out);
+				out.println("<p>");
+			}
+		} else {
+			out.println("No failures reported.");
+		}
+	}
 	/**
 	 * Prints the header of the report
 	 */
@@ -82,8 +105,7 @@
 	 */
 	protected void printHTMLHeader(PrintWriter out) {
 		StringBuffer buf = new StringBuffer();
-		buf.append("<html>\n<head>\n<title>Leapfrog Performance Test Output Page</title>");
-		buf.append("<author>AutoGen imagebuilder.tests.LoggingPerformanceTestResult</author>\n");
+		buf.append("<html>\n<head>\n<title>Eclipse Performance Test Output Page</title>");
 		buf.append("</head>\n<body>\n");
 		out.println(buf.toString());
 	}
@@ -101,32 +123,31 @@
 	protected void printTimings(PrintWriter out) {
 		out.println("<h3>Timing summary</h3>");
 		out.println("<ul>");
-		
+
 		// print out all timing results to the console
-		Enumeration enum = fTimerList.elements();
-		while (enum.hasMoreElements()) {
-			PerformanceTimer timer = (PerformanceTimer)enum.nextElement();
+		for (Iterator it = timerList.iterator(); it.hasNext();) {
+			PerformanceTimer timer = (PerformanceTimer) it.next();
 			out.println("<li>" + timer.getName() + " : " + timer.getElapsedTime() + " ms</li>");
 		}
 		out.println("</ul>");
 	}
-/**
- * Start the timer with the given name.  If the timer has already
- * been created, send it a startTiming message.  If not, create it
- * and send the new timer the startTiming message.
- */
+	/**
+	 * Start the timer with the given name.  If the timer has already
+	 * been created, send it a startTiming message.  If not, create it
+	 * and send the new timer the startTiming message.
+	 */
 
- public synchronized void startTimer(String timerName) {
-	super.startTimer(timerName);
-	//log("Starting timer: " + timerName);
- } 
-/**
- * Look up the timer with the given name and send it a stopTiming
- * message.  If the timer does not exist, report an error.
- */
+	public synchronized void startTimer(String timerName) {
+		super.startTimer(timerName);
+		//log("Starting timer: " + timerName);
+	}
+	/**
+	 * Look up the timer with the given name and send it a stopTiming
+	 * message.  If the timer does not exist, report an error.
+	 */
 
- public synchronized void stopTimer(String timerName) {
-	super.stopTimer(timerName);
-	//log("Stopping timer: " + timerName);
- } 
+	public synchronized void stopTimer(String timerName) {
+		super.stopTimer(timerName);
+		//log("Stopping timer: " + timerName);
+	}
 }
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
index ad4fc61..a02a1bb 100644
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
+++ b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
@@ -1,16 +1,16 @@
 /**********************************************************************
- * Copyright (c) 2000, 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
  * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
  * 
  * Contributors: 
  * IBM - Initial API and implementation
  **********************************************************************/
 package org.eclipse.core.tests.harness;
 
-import java.io.PrintStream;
+import java.io.PrintWriter;
 import java.util.*;
 
 import junit.framework.*;
@@ -19,123 +19,133 @@
  * Test result for a performance test.  Keeps track of all timers that
  * have been created within the test. 
  */
-
 public class PerformanceTestResult extends TestResult {
-	Hashtable fTimers = new Hashtable();
-	Vector fTimerList = new Vector();
-/**
- * PerformanceTestResult constructor comment.
- */
-public PerformanceTestResult() {
-	super();
-}
-/**
- * Informs the result that a test was completed.
- */
-public synchronized void endTest(Test test) {
-	print();
-}
-/**
- * Prints the test result
- */
-
-
-public synchronized void print() {
-	stopTimers();
-	printHeader(System.out);
-	printErrors(System.out);
-	printTimings(System.out);
-}
-/**
- * Prints the errors to the standard output
- */
-protected void printErrors(PrintStream out) {
-	int count = errorCount();
-	if (count != 0) {
-		if (count == 1)
-			out.println("There was " + count + " error:");
-		else
-			out.println("There were " + count + " errors:");
-		int i = 1;
-		for (Enumeration e = errors(); e.hasMoreElements(); i++) {
-			TestFailure failure = (TestFailure) e.nextElement();
-			out.println(i + ") " + failure.failedTest());
-			failure.thrownException().printStackTrace();
+	protected PrintWriter output;
+	protected ArrayList timerList = new ArrayList();
+	protected HashMap timers = new HashMap();
+	
+	public PerformanceTestResult() {
+		this(new PrintWriter(System.out));
+	}
+	public PerformanceTestResult(PrintWriter outputStream) {
+		this.output = outputStream;
+	}
+	/**
+	 * Informs the result that a test was completed.
+	 */
+	public synchronized void endTest(Test test) {
+		print();
+	}
+	/**
+	 * Prints the test result
+	 */
+	public synchronized void print() {
+		stopTimers();
+		printHeader(output);
+		printErrors(output);
+		printFailures(output);
+		printTimings(output);
+	}
+	/**
+	 * Prints the errors to the output
+	 */
+	protected void printErrors(PrintWriter out) {
+		int count = errorCount();
+		if (count != 0) {
+			if (count == 1)
+				out.println("There was " + count + " error:");
+			else
+				out.println("There were " + count + " errors:");
+			int i = 1;
+			for (Enumeration e = errors(); e.hasMoreElements(); i++) {
+				TestFailure failure = (TestFailure) e.nextElement();
+				out.println(i + ") " + failure.failedTest());
+				failure.thrownException().printStackTrace(out);
+			}
 		}
 	}
-}
-/**
- * Prints the header of the report
- */
-protected void printHeader(PrintStream out) {
-	if (wasSuccessful()) {
-		out.println();
-		out.print("OK");
-		out.println(" (" + runCount() + " tests)");
-	} else {
-		out.println();
-		out.println("!!!FAILURES!!!");
-		out.println("Test Results:");
-		out.println("Run: " + runCount() + " Failures: " + failureCount() + " Errors: " + errorCount());
+	/**
+	 * Prints the failures to the output
+	 */
+   protected void printFailures(PrintWriter out) {
+	   int count = failureCount();
+	   if (count != 0) {
+		   if (count == 1)
+			   out.println("There was " + count + " failure:");
+		   else
+			   out.println("There were " + count + " failures:");
+		   int i = 1;
+		   for (Enumeration e = failures(); e.hasMoreElements(); i++) {
+			   TestFailure failure = (TestFailure) e.nextElement();
+			   out.println(i + ") " + failure.failedTest());
+			   failure.thrownException().printStackTrace(out);
+		   }
+	   }
+   }
+	/**
+	 * Prints the header of the report
+	 */
+	protected void printHeader(PrintWriter out) {
+		if (wasSuccessful()) {
+			out.println();
+			out.print("OK");
+			out.println(" (" + runCount() + " tests)");
+		} else {
+			out.println();
+			out.println("!!!FAILURES!!!");
+			out.println("Test Results:");
+			out.println("Run: " + runCount() + " Failures: " + failureCount() + " Errors: " + errorCount());
+		}
 	}
-}
 	/**
 	 * Prints the timings of the result.
 	 */
-
-	protected void printTimings(PrintStream out) {
-		
+	protected void printTimings(PrintWriter out) {
 		// print out all timing results to the console
-		Enumeration enum = fTimerList.elements();
-		while (enum.hasMoreElements()) {
-			PerformanceTimer timer = (PerformanceTimer)enum.nextElement();
+		for (Iterator it = timerList.iterator(); it.hasNext();) {
+			PerformanceTimer timer = (PerformanceTimer) it.next();
 			out.println("Timing " + timer.getName() + " : " + timer.getElapsedTime() + " ms ");
 		}
 	}
-/**
- * Start the test
- */
-
-public synchronized void startTest(Test test) {
-	super.startTest(test);
-	System.out.print(".");
-}
-/**
- * Start the timer with the given name.  If the timer has already
- * been created, send it a startTiming message.  If not, create it
- * and send the new timer the startTiming message.
- */
-
- public synchronized void startTimer(String timerName) {
-	PerformanceTimer timer = (PerformanceTimer) fTimers.get(timerName);
-	if( timer == null) {
-		timer = new PerformanceTimer(timerName);
-		fTimers.put(timerName, timer);
-		fTimerList.addElement(timer);
+	/**
+	 * Start the test
+	 */
+	public synchronized void startTest(Test test) {
+		super.startTest(test);
+		System.out.print(".");
 	}
-	timer.startTiming();
- } 
-/**
- * Look up the timer with the given name and send it a stopTiming
- * message.  If the timer does not exist, report an error.
- */
+	/**
+	 * Start the timer with the given name.  If the timer has already
+	 * been created, send it a startTiming message.  If not, create it
+	 * and send the new timer the startTiming message.
+	 */
 
- public synchronized void stopTimer(String timerName) {
-	PerformanceTimer timer = (PerformanceTimer) fTimers.get(timerName);
-	if (timer == null) {
-		throw new Error(timerName + " is not a valid timer name ");
+	public synchronized void startTimer(String timerName) {
+		PerformanceTimer timer = (PerformanceTimer) timers.get(timerName);
+		if (timer == null) {
+			timer = new PerformanceTimer(timerName);
+			timers.put(timerName, timer);
+			timerList.add(timer);
+		}
+		timer.startTiming();
 	}
-	timer.stopTiming();
- } 
+	/**
+	 * Look up the timer with the given name and send it a stopTiming
+	 * message.  If the timer does not exist, report an error.
+	 */
+	public synchronized void stopTimer(String timerName) {
+		PerformanceTimer timer = (PerformanceTimer) timers.get(timerName);
+		if (timer == null) {
+			throw new Error(timerName + " is not a valid timer name ");
+		}
+		timer.stopTiming();
+	}
 	/**
 	 * Stops all timers
 	 */
-
 	protected void stopTimers() {
-
-		Enumeration enum = fTimerList.elements();
-		while (enum.hasMoreElements()) {
-			((PerformanceTimer) enum.nextElement()).stopTiming();
-		}	
+		for (Iterator it = timerList.iterator(); it.hasNext();) {
+			((PerformanceTimer) it.next()).stopTiming();
+		}
 	}
 }