1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
import java.util.ArrayList;
import java.util.Iterator;
public class PerformanceLog {
private ArrayList log = new ArrayList();
private long testTime;
public static class ZLogEntry {
public String name;
public long time;
public ZLogEntry(String aName, long aTime) {
name = aName;
time = aTime;
}
}
public void startTest() {
Runtime.getRuntime().gc();
testTime = System.currentTimeMillis();
}
public void endTest(String name) {
testTime = System.currentTimeMillis() - testTime;
addEntry(name, testTime);
System.gc();
}
public void addEntry(String aName, long aTime) {
log.add(new ZLogEntry(aName, aTime));
}
public void clear() {
log.clear();
}
public void writeLog() {
System.out.println();
System.out.println("Test data for input into spreadsheet:");
System.out.println();
Iterator i = log.iterator();
while (i.hasNext()) {
ZLogEntry each = (ZLogEntry) i.next();
System.out.println(each.time);
}
System.out.println();
System.out.println("Labled test results, see above for simple column \n of times for input into spreadsheet:");
System.out.println();
i = log.iterator();
while (i.hasNext()) {
ZLogEntry each = (ZLogEntry) i.next();
System.out.println(each.name + ", " + each.time);
}
}
}
|