|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PerformanceMeter
public class PerformanceMeter
A class that test the performance of methods within an object. It relies on
the ExecutingMethod class, thus all restrictions mentioned there
apply.
This class is costructed with an object to be monitored. On construct, all methods of the declaring class of this object with a unique name are recorded. To actually do the metering, code your methods like:
public void meterMe() {
performancemeter.enter();
...
performanemeter.exit();
return;
}
This records the execution time at each method call. Statistics can then
be queried from the performance meter.
| Nested Class Summary | |
|---|---|
protected static class |
PerformanceMeter.BoundList<T>
Bound lists do not grow above a certain size, they lose elemtns at their head, but retain the very first entry. |
| Field Summary | |
|---|---|
private Map<Method,Long> |
enter
A lookup table linking method names to enter times to recall for exit. |
private Map<Method,PerformanceMeter.BoundList<Long>> |
table
A lookup table matching method names to lists of executin times. |
| Constructor Summary | |
|---|---|
PerformanceMeter(Object monitor)
Constructs a new performance meter for the given object. |
|
| Method Summary | |
|---|---|
void |
enter()
Called from within a method that should be monitored at method start. |
void |
exit()
Called from within a method that should be monitored at method end. |
long |
getFirstTime(Method monitor)
Get the first execution time for the given method or -1 if this method was never monitored. |
long |
getLastTime(Method monitor)
Get the last execution time for the given method or -1 if this method was never monitored. |
long |
getMaximumTime(Method monitor)
Get the maximum time for the given method or -1 if this method was never monitored. |
double |
getMeanTime(Method monitor)
Gets the arithmetic average. |
double |
getMedianTime(Method monitor)
Gets the median execution time. |
long |
getMinimumTime(Method monitor)
Get the minimum time for the given method or -1 if this method was never monitored. |
void |
printStatistics()
Prints statistic to system.out |
void |
printStatistics(PrintStream out)
Prints statistic to system.out |
void |
printStatistics(PrintWriter out)
Prints statistic to system.out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Map<Method,PerformanceMeter.BoundList<Long>> table
private Map<Method,Long> enter
| Constructor Detail |
|---|
public PerformanceMeter(Object monitor)
PerformanceMeter.BoundList. Whenever the enter
method is called, we rocord the system time, which is added to the
methods list at a call to exit().
| Method Detail |
|---|
public void enter()
public void exit()
public long getMinimumTime(Method monitor)
public long getMaximumTime(Method monitor)
public long getFirstTime(Method monitor)
public long getLastTime(Method monitor)
public double getMedianTime(Method monitor)
public double getMeanTime(Method monitor)
public void printStatistics()
public void printStatistics(PrintStream out)
public void printStatistics(PrintWriter out)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||