Class StopWatch


  • public final class StopWatch
    extends java.lang.Object
    A very simple stop watch.

    This implementation is not thread safe and can only time one task at any given time.

    • Constructor Summary

      Constructors 
      Constructor Description
      StopWatch()
      Starts the stop watch
      StopWatch​(boolean started)
      Creates the stop watch
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isStarted()  
      void restart()
      Starts or restarts the stop watch
      long stop()
      Stops the stop watch
      long taken()
      Returns the time taken in millis.
      • Methods inherited from class java.lang.Object

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

      • StopWatch

        public StopWatch()
        Starts the stop watch
      • StopWatch

        public StopWatch​(boolean started)
        Creates the stop watch
        Parameters:
        started - whether it should start immediately
    • Method Detail

      • isStarted

        public boolean isStarted()
        Returns:
        check if the StopWatch has already been started.
      • restart

        public void restart()
        Starts or restarts the stop watch
      • stop

        public long stop()
        Stops the stop watch
        Returns:
        the time taken in millis.
      • taken

        public long taken()
        Returns the time taken in millis.
        Returns:
        time in millis