FileDocCategorySizeDatePackage
PerfStatCollector.javaAPI DocAndroid 1.5 API8552Wed May 06 22:41:04 BST 2009com.google.coretests

PerfStatCollector

public class PerfStatCollector extends Object implements TestListener

Fields Summary
public boolean
listAll
public boolean
listBad
public long
thresholdDuration
public boolean
twoLines
public boolean
bigMarking
private static boolean
havePreciseTime
ArrayList
items
Item
current
PrintStream
fWriter
int
fColumn
Constructors Summary
public PerfStatCollector(PrintStream writer)


        
        fWriter= writer;
        items = new ArrayList();
    
Methods Summary
public voidaddError(junit.framework.Test test, java.lang.Throwable t)

see
junit.framework.TestListener#addError(Test, Throwable)

        current.res = -1;
    
public voidaddFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)

see
junit.framework.TestListener#addFailure(Test, AssertionFailedError)

        current.res = -2;
    
private longcurrentTimeMillis()

        if (havePreciseTime) {
            return VMDebug.threadCpuTimeNanos() / 1000;
        } else {
            return System.currentTimeMillis();
        }
    
synchronized voiddigest()

        int totalCnt = 0;
        int adhocRelevantCnt = 0;
        int histRelevantCnt = 0;
        long evalStartTime = System.currentTimeMillis();
        PrintStream out = fWriter;
        out.println("Failure and Performance Statistics:");
        Iterator<Item> r = items.iterator();
        while (r.hasNext()) {
            Item item = r.next();
            item.update(listBad, thresholdDuration);
            if (item.histRelevance != 0) {
                item.print(out, bigMarking);
                histRelevantCnt++;
            }
            if (item.adhocRelevance != 0) {
                if (item.checkPrint(out))
                    adhocRelevantCnt++;
            }
            if (listAll) item.checkPrint(out);
            totalCnt++;
        }
        long evalDuration = System.currentTimeMillis() - evalStartTime;
        out.println();
        out.print(totalCnt); out.println(" tests run totally.");
        out.print(histRelevantCnt);
                out.println(" tests listed due to historical relevance.");
//        out.print(adhocRelevantCnt);
//                out.println(" tests listed due to ad-hoc-relevance.");
//        out.print(totalCnt - histRelevantCnt - adhocRelevantCnt);
//                out.println(" tests NOT listed due to relevance.");
        out.println();
        out.print("Time used in Statistics Acquisition: ");
        out.print(evalDuration);
        out.print("ms");
        out.println();
    
public voidendTest(junit.framework.Test test)

see
junit.framework.TestListener#endTest(Test)

        current.duration = currentTimeMillis() - current.startTime;
    
public java.io.PrintStreamgetWriter()

        return fWriter;
    
public voidstartTest(junit.framework.Test test)

see
junit.framework.TestListener#startTest(Test)

        System.gc();
        current = new Item();
        current.test = test;
        current.startTime = currentTimeMillis();
        items.add(current);