FileDocCategorySizeDatePackage
TestRunData.javaAPI DocApache Lucene 2.1.04500Wed Feb 14 10:46:16 GMT 2007org.apache.lucene.benchmark.stats

TestRunData

public class TestRunData extends Object
This class holds series of TimeData related to a single test run. TimeData values may contribute to different measurements, so this class provides also some useful methods to separate them.
author
Andrzej Bialecki <ab@getopt.org>

Fields Summary
private String
id
private long
start
Start and end time of this test run.
private long
end
private LinkedHashMap
data
Constructors Summary
public TestRunData()


    
public TestRunData(String id)

    this.id = id;
  
Methods Summary
public voidaddData(TimeData td)
Add a data point.

    td.recordMemUsage();
    Vector v = (Vector) data.get(td.name);
    if (v == null) {
      v = new Vector();
      data.put(td.name, v);
    }
    v.add(td.clone());
  
public voidendRun()
Mark the ending time of this test run.

    end = System.currentTimeMillis();
  
public java.util.LinkedHashMapgetData()

        return data;
    
public longgetEnd()

        return end;
    
public java.lang.StringgetId()

        return id;
    
public java.util.CollectiongetLabels()
Get a list of all available types of data points.

    return data.keySet();
  
public MemUsagegetMemUsage(java.lang.String label)
Get memory usage stats. for a given data type.

    Vector v = (Vector) data.get(label);
      if (v == null)
      {
          return null;
      }
    MemUsage res = new MemUsage();
    res.minFree = Long.MAX_VALUE;
    res.minTotal = Long.MAX_VALUE;
    long avgFree = 0L, avgTotal = 0L;
    for (int i = 0; i < v.size(); i++) {
      TimeData td = (TimeData) v.get(i);
        if (res.maxFree < td.freeMem)
        {
            res.maxFree = td.freeMem;
        }
        if (res.maxTotal < td.totalMem)
        {
            res.maxTotal = td.totalMem;
        }
        if (res.minFree > td.freeMem)
        {
            res.minFree = td.freeMem;
        }
        if (res.minTotal > td.totalMem)
        {
            res.minTotal = td.totalMem;
        }
      avgFree += td.freeMem;
      avgTotal += td.totalMem;
    }
    res.avgFree = avgFree / v.size();
    res.avgTotal = avgTotal / v.size();
    return res;
  
public longgetStart()

        return start;
    
public TimeDatagetTotals(java.lang.String label)
Get total values from all data points of a given type.

    Vector v = (Vector) data.get(label);
      if (v == null)
      {
          return null;
      }
    TimeData res = new TimeData("TOTAL " + label);
    for (int i = 0; i < v.size(); i++) {
      TimeData td = (TimeData) v.get(i);
      res.count += td.count;
      res.elapsed += td.elapsed;
    }
    return res;
  
public java.util.VectorgetTotals()
Get total values from all data points of all types.

return
a list of TimeData values for all types.

    Collection labels = getLabels();
    Vector v = new Vector();
    Iterator it = labels.iterator();
    while (it.hasNext()) {
      TimeData td = getTotals((String) it.next());
      v.add(td);
    }
    return v;
  
public voidsetId(java.lang.String id)

        this.id = id;
    
public voidstartRun()
Mark the starting time of this test run.

    start = System.currentTimeMillis();
  
public java.lang.StringtoString()
Return a string representation.

    StringBuffer sb = new StringBuffer();
    Collection labels = getLabels();
    Iterator it = labels.iterator();
    while (it.hasNext()) {
      String label = (String) it.next();
        sb.append(id).append("-").append(label).append(" ").append(getTotals(label).toString(false)).append(" ");
        sb.append(getMemUsage(label).toScaledString(1024 * 1024, "MB")).append("\n");
    }
    return sb.toString();