Methods Summary |
---|
public synchronized void | callIn()
concurrentCalls++;
if (concurrentCalls > maxConcurrentCalls)
maxConcurrentCalls = concurrentCalls;
|
public synchronized void | callOut()
concurrentCalls--;
|
public java.util.Map | getStats()Access the current collection of method invocation statistics
return methodStats;
|
public void | resetStats()Resets all current TimeStatistics.
synchronized (methodStats)
{
Iterator iter = methodStats.values().iterator();
while (iter.hasNext())
{
TimeStatistic stat = (TimeStatistic) iter.next();
stat.reset();
}
}
maxConcurrentCalls = 0;
lastResetTime = System.currentTimeMillis();
|
public java.lang.String | toString()Generate an XML fragement for the InvocationStatistics. The format is
...
StringBuffer tmp = new StringBuffer("<InvocationStatistics concurrentCalls='");
tmp.append(concurrentCalls);
tmp.append("' >\n");
HashMap copy = new HashMap(methodStats);
Iterator iter = copy.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry) iter.next();
TimeStatistic stat = (TimeStatistic) entry.getValue();
if (stat != null)
{
tmp.append("<method name='");
tmp.append(entry.getKey());
tmp.append("' count='");
tmp.append(stat.count);
tmp.append("' minTime='");
tmp.append(stat.minTime);
tmp.append("' maxTime='");
tmp.append(stat.maxTime);
tmp.append("' totalTime='");
tmp.append(stat.totalTime);
tmp.append("' />\n");
}
}
tmp.append("</InvocationStatistics>");
return tmp.toString();
|
public void | updateStats(java.lang.reflect.Method m, long elapsed)Update the TimeStatistic for the given method. This synchronizes on
m to ensure that the TimeStatistic for m is updated atomically.
TimeStatistic stat = (TimeStatistic) methodStats.get(m.getName());
if (stat == null)
{
stat = new TimeStatistic();
methodStats.put(m.getName(), stat);
}
stat.count++;
stat.totalTime += elapsed;
if (stat.minTime > elapsed)
stat.minTime = elapsed;
if (stat.maxTime < elapsed)
stat.maxTime = elapsed;
|