physics
Class Counter
java.lang.Object
physics.Counter
public final class Counter
- extends java.lang.Object
A counter is a mutable ADT used to instrument code to
measure the time of blocks of code.
|
Constructor Summary |
Counter(java.lang.String blockName)
Constructs a Counter with the given block name |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Counter
public Counter(java.lang.String blockName)
- Constructs a Counter with the given block name
- Parameters:
blockName - name to use for this counter
- Throws:
java.lang.IllegalArgumentException - if blockName is null
java.lang.IllegalArgumentException - if the constructor has already been called with the given blockName
getCounters
public static final java.util.Collection<Counter> getCounters()
- Returns:
- Collection of Counters containing all Counters ever created
getAllResults
public static final java.lang.String getAllResults()
- Returns:
- concatenation of c.getResult() for all Counters ever created
begin
public final void begin()
end
public final void end()
- Throws:
java.lang.IllegalStateException - if begin() has not been called more times than end() on this counter
reset
public void reset()
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal
getTotalInvocations
public final int getTotalInvocations()
- Returns:
- this.totalInvocations
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal
getTotalTime
public final long getTotalTime()
- Returns:
- this.totalTime
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal
getAverageTime
public final double getAverageTime()
- Returns:
- this.averageTime
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal
isRecursionDetected
public final boolean isRecursionDetected()
- Returns:
- this.recursionDetected
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal
getResult
public java.lang.String getResult()
- Returns:
- a String summarizing the results of this counter
- Throws:
java.lang.IllegalStateException - if the number of calls to begin() and end() was not equal