FileDocCategorySizeDatePackage
TimeData.javaAPI DocApache Lucene 2.2.02923Sat Jun 16 22:21:00 BST 2007org.apache.lucene.benchmark.stats

TimeData

public class TimeData extends Object
This class holds a data point measuring speed of processing.
author
Andrzej Bialecki <ab@getopt.org>

Fields Summary
public String
name
Name of the data point - usually one of a data series with the same name
public long
count
Number of records processed.
public long
elapsed
Elapsed time in milliseconds.
private long
delta
public long
freeMem
Free memory at the end of measurement interval.
public long
totalMem
Total memory at the end of measurement interval.
Constructors Summary
public TimeData()


    
public TimeData(String name)

    this.name = name;
  
Methods Summary
protected java.lang.Objectclone()

    TimeData td = new TimeData(name);
    td.name = name;
    td.elapsed = elapsed;
    td.count = count;
    td.delta = delta;
    td.freeMem = freeMem;
    td.totalMem = totalMem;
    return td;
  
public static java.lang.StringgetLabels()
Get a short legend for toString() output.

    return "# count\telapsed\trec/s\tfreeMem\ttotalMem";
  
public doublegetRate()
Get rate of processing, defined as number of processed records per second.

    double rps = (double) count * 1000.0 / (double) (elapsed>0 ? elapsed : 1); // assume atleast 1ms for any countable op
    return rps;
  
public voidrecordMemUsage()
Record memory usage.

    freeMem = Runtime.getRuntime().freeMemory();
    totalMem = Runtime.getRuntime().totalMemory();
  
public voidreset()
Reset counters.

    count = 0;
    elapsed = 0L;
    delta = elapsed;
  
public voidstart()
Start counting elapsed time.

    delta = System.currentTimeMillis();
  
public voidstop()
Stop counting elapsed time.

    count++;
    elapsed += (System.currentTimeMillis() - delta);
  
public java.lang.StringtoString()

 return toString(true); 
public java.lang.StringtoString(boolean withMem)
Return a tab-seprated string containing this data.

param
withMem if true, append also memory information
return
The String

    StringBuffer sb = new StringBuffer();
    sb.append(count + "\t" + elapsed + "\t" + getRate());
    if (withMem) sb.append("\t" + freeMem + "\t" + totalMem);
    return sb.toString();