Methods Summary |
---|
protected java.lang.Object | clone()
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.String | getLabels()Get a short legend for toString() output.
return "# count\telapsed\trec/s\tfreeMem\ttotalMem";
|
public double | getRate()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 void | recordMemUsage()Record memory usage.
freeMem = Runtime.getRuntime().freeMemory();
totalMem = Runtime.getRuntime().totalMemory();
|
public void | reset()Reset counters.
count = 0;
elapsed = 0L;
delta = elapsed;
|
public void | start()Start counting elapsed time.
delta = System.currentTimeMillis();
|
public void | stop()Stop counting elapsed time.
count++;
elapsed += (System.currentTimeMillis() - delta);
|
public java.lang.String | toString() return toString(true);
|
public java.lang.String | toString(boolean withMem)Return a tab-seprated string containing this data.
StringBuffer sb = new StringBuffer();
sb.append(count + "\t" + elapsed + "\t" + getRate());
if (withMem) sb.append("\t" + freeMem + "\t" + totalMem);
return sb.toString();
|