Split our reports into the default report and a separate report for the giant

morass of profiling data.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5709 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-04-06 21:13:59 +00:00
parent fd321d6f2d
commit 3b1024651a
3 changed files with 85 additions and 69 deletions
@@ -30,7 +30,6 @@ import com.samskivert.util.StringUtil;
* historical size and the results of unit profiling if enabled.
*/
public class ReportingInvoker extends Invoker
implements ReportManager.Reporter
{
/**
* Creates a new reporting invoker. The instance will be registered with the report manager
@@ -40,44 +39,8 @@ public class ReportingInvoker extends Invoker
{
super(name, resultsQueue);
if (PERF_TRACK) {
repmgr.registerReporter(this);
}
}
// from interface ReportManager.Reporter
public void appendReport (StringBuilder buf, long now, long sinceLast, boolean reset)
{
buf.append("* " + getName() + ":\n");
int qsize = _queue.size();
buf.append("- Queue size: ").append(qsize).append("\n");
synchronized (this) {
buf.append("- Max queue size: ").append(_maxQueueSize).append("\n");
buf.append("- Units executed: ").append(_unitsRun);
long runPerSec = (sinceLast == 0) ? 0 : 1000l*_unitsRun/sinceLast;
buf.append(" (").append(runPerSec).append("/s)\n");
if (_currentUnit != null) {
String uname = StringUtil.safeToString(_currentUnit);
buf.append("- Current unit: ").append(uname).append(" ");
buf.append(now-_currentUnitStart).append("ms\n");
}
if (reset) {
_maxQueueSize = qsize;
_unitsRun = 0;
}
}
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
for (Object key : _tracker.keySet()) {
UnitProfile profile = _tracker.get(key);
if (key instanceof Class) {
key = StringUtil.shortClassName((Class<?>)key);
}
buf.append(" ").append(key).append(" ");
buf.append(profile).append("\n");
if (reset) {
profile.clear();
}
}
repmgr.registerReporter(ReportManager.DEFAULT_TYPE, _defrep);
repmgr.registerReporter(ReportManager.PROFILE_TYPE, _profrep);
}
}
@@ -111,6 +74,52 @@ public class ReportingInvoker extends Invoker
}
}
/** Generates a report on our runtime behavior. */
protected ReportManager.Reporter _defrep = new ReportManager.Reporter() {
public void appendReport (StringBuilder buf, long now, long sinceLast, boolean reset) {
buf.append("* " + getName() + ":\n");
int qsize = _queue.size();
buf.append("- Queue size: ").append(qsize).append("\n");
synchronized (this) {
buf.append("- Max queue size: ").append(_maxQueueSize).append("\n");
buf.append("- Units executed: ").append(_unitsRun);
long runPerSec = (sinceLast == 0) ? 0 : 1000l*_unitsRun/sinceLast;
buf.append(" (").append(runPerSec).append("/s)\n");
if (_currentUnit != null) {
String uname = StringUtil.safeToString(_currentUnit);
buf.append("- Current unit: ").append(uname).append(" ");
buf.append(now-_currentUnitStart).append("ms\n");
}
if (reset) {
_maxQueueSize = qsize;
_unitsRun = 0;
}
}
}
};
/** Generates a report with our profiling data. */
protected ReportManager.Reporter _profrep = new ReportManager.Reporter() {
public void appendReport (StringBuilder buf, long now, long sinceLast, boolean reset) {
buf.append("* " + getName() + ":\n");
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
for (Object key : _tracker.keySet()) {
UnitProfile profile = _tracker.get(key);
if (key instanceof Class) {
key = StringUtil.shortClassName((Class<?>)key);
}
buf.append(" ").append(key).append(" ");
buf.append(profile).append("\n");
if (reset) {
profile.clear();
}
}
} else {
buf.append(" - Unit profiling disabled.\n");
}
}
};
/** The largest queue size since our last report. */
protected long _maxQueueSize;