Class UtilTimer


  • public class UtilTimer
    extends java.lang.Object
    Timer handling utility Utility class for simple reporting of the progress of a process. Steps are labelled, and the time between each label (or message) and the time since the start are reported in each call to timerString.
    • Constructor Summary

      Constructors 
      Constructor Description
      UtilTimer()
      Default constructor.
      UtilTimer​(java.lang.String timerName, boolean start)  
      UtilTimer​(java.lang.String timerName, boolean start, boolean log)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeTimer​(java.lang.String timerName)  
      static void closeTimer​(java.lang.String timerName, java.lang.String message)  
      static void closeTimer​(java.lang.String timerName, java.lang.String message, java.lang.String module)  
      boolean getLog()
      Gets the value of the log member, denoting whether log output is off or not
      java.lang.String getName()  
      static UtilTimer getTimer​(java.lang.String timerName)  
      static UtilTimer getTimer​(java.lang.String timerName, boolean log)  
      boolean isRunning()  
      static UtilTimer makeTimer()  
      double secondsSinceLast()
      Returns the number of seconds since the last time timerString was called
      double secondsSinceStart()
      Returns the number of seconds since the timer started
      void setLog​(boolean log)
      Sets the value of the log member, denoting whether log output is off or not
      void startTimer()  
      static void timerLog​(java.lang.String timerName, java.lang.String message, java.lang.String module)  
      java.lang.String timerString​(int level, java.lang.String message)
      Creates a string with information including the passed message, the time since the last call, and the time since the beginning.
      java.lang.String timerString​(java.lang.String message)
      Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning
      java.lang.String timerString​(java.lang.String message, java.lang.String module)
      Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning
      long timeSinceLast()
      Returns the number of milliseconds since the last time timerString was called
      long timeSinceStart()
      Returns the number of milliseconds since the timer started
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • module

        public static final java.lang.String module
      • staticTimers

        protected static final java.util.concurrent.ConcurrentHashMap<java.lang.String,​UtilTimer> staticTimers
      • timerName

        protected java.lang.String timerName
      • lastMessage

        protected java.lang.String lastMessage
      • realStartTime

        protected long realStartTime
      • startTime

        protected long startTime
      • lastMessageTime

        protected long lastMessageTime
      • running

        protected boolean running
      • log

        protected boolean log
    • Constructor Detail

      • UtilTimer

        public UtilTimer()
        Default constructor. Starts the timer.
      • UtilTimer

        public UtilTimer​(java.lang.String timerName,
                         boolean start)
      • UtilTimer

        public UtilTimer​(java.lang.String timerName,
                         boolean start,
                         boolean log)
    • Method Detail

      • makeTimer

        public static UtilTimer makeTimer()
      • startTimer

        public void startTimer()
      • getName

        public java.lang.String getName()
      • isRunning

        public boolean isRunning()
      • timerString

        public java.lang.String timerString​(java.lang.String message)
        Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning
        Parameters:
        message - A message to put into the timer String
        Returns:
        A String with the timing information, the timer String
      • timerString

        public java.lang.String timerString​(java.lang.String message,
                                            java.lang.String module)
        Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning
        Parameters:
        message - A message to put into the timer String
        module - The debug/log module/thread to use, can be null for root module
        Returns:
        A String with the timing information, the timer String
      • secondsSinceStart

        public double secondsSinceStart()
        Returns the number of seconds since the timer started
        Returns:
        The number of seconds since the timer started
      • secondsSinceLast

        public double secondsSinceLast()
        Returns the number of seconds since the last time timerString was called
        Returns:
        The number of seconds since the last time timerString was called
      • timeSinceStart

        public long timeSinceStart()
        Returns the number of milliseconds since the timer started
        Returns:
        The number of milliseconds since the timer started
      • timeSinceLast

        public long timeSinceLast()
        Returns the number of milliseconds since the last time timerString was called
        Returns:
        The number of milliseconds since the last time timerString was called
      • setLog

        public void setLog​(boolean log)
        Sets the value of the log member, denoting whether log output is off or not
        Parameters:
        log - The new value of log
      • getLog

        public boolean getLog()
        Gets the value of the log member, denoting whether log output is off or not
        Returns:
        The value of log
      • timerString

        public java.lang.String timerString​(int level,
                                            java.lang.String message)
        Creates a string with information including the passed message, the time since the last call, and the time since the beginning. This version allows an integer level to be specified to improve readability of the output.
        Parameters:
        level - Integer specifying how many levels to indent the timer string so the output can be more easily read through nested method calls.
        message - A message to put into the timer String
        Returns:
        A String with the timing information, the timer String
      • getTimer

        public static UtilTimer getTimer​(java.lang.String timerName)
      • getTimer

        public static UtilTimer getTimer​(java.lang.String timerName,
                                         boolean log)
      • timerLog

        public static void timerLog​(java.lang.String timerName,
                                    java.lang.String message,
                                    java.lang.String module)
      • closeTimer

        public static void closeTimer​(java.lang.String timerName)
      • closeTimer

        public static void closeTimer​(java.lang.String timerName,
                                      java.lang.String message)
      • closeTimer

        public static void closeTimer​(java.lang.String timerName,
                                      java.lang.String message,
                                      java.lang.String module)