Class MOATimer

java.lang.Object
at.gv.egovernment.moaspss.util.MOATimer

public class MOATimer extends Object
A timer utility for named timers.
  • Constructor Details

    • MOATimer

      protected MOATimer()
      Create a new MOATimer. Protected to disallow multiple instances.
  • Method Details

    • getInstance

      public static MOATimer getInstance()
      Return the single instance of this class.
      Returns:
      The single instance of this class.
    • startTiming

      public void startTiming(Object id)
      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

      public void stopTiming(Object id)
      Stop timing an action.
      Parameters:
      id - The action ID.
    • duration

      public long duration(Object id)
      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() and stopTiming(). If only startTiming() has been called for the action, then current difference to the system time is returned. If no timing exists for the action, - 1 is returned.
    • durationAsString

      public String durationAsString(Object id)
      Get the duration of an action, as a nicely formatted String.
      Parameters:
      id - The action ID.
      Returns:
      String The duration() as a String.
    • clearTiming

      public void clearTiming(String id)
      Remove a timing.
      Parameters:
      id - The action ID.