Package at.gv.egovernment.moaspss.util
Class MOATimer
java.lang.Object
at.gv.egovernment.moaspss.util.MOATimer
A timer utility for named timers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearTiming(String id) Remove a timing.longGet the duration of an action.Get the duration of an action, as a nicely formattedString.static MOATimerReturn the single instance of this class.voidstartTiming(Object id) Start timing a certain action.voidstopTiming(Object id) Stop timing an action.
-
Constructor Details
-
MOATimer
protected MOATimer()Create a newMOATimer. Protected to disallow multiple instances.
-
-
Method Details
-
getInstance
Return the single instance of this class.- Returns:
- The single instance of this class.
-
startTiming
Start timing a certain action. The timing belonging to the action ID is garbage collected as soon as there exists no other reference to the action ID.- Parameters:
id- The action ID.
-
stopTiming
Stop timing an action.- Parameters:
id- The action ID.
-
duration
Get the duration of an action.- Parameters:
id- The action ID for which to compute the duration.- Returns:
- long The duration in milliseconds between calls to
startTiming()andstopTiming(). If onlystartTiming()has been called for the action, then current difference to the system time is returned. If no timing exists for the action,- 1is returned.
-
durationAsString
Get the duration of an action, as a nicely formattedString.- Parameters:
id- The action ID.- Returns:
- String The
duration()as aString.
-
clearTiming
Remove a timing.- Parameters:
id- The action ID.
-