Class StopWatch


  • public class StopWatch
    extends java.lang.Object
    Simple timer implementation.

    To count the time, a certain process runs, stop it's execution time as follows:
     StopWatch timer = new StopWatch("Stopping my process");
     // run your process
     long elapsedTime = timer.stop();
     // elapsedTime now contains the time, your process run. You may print it to a logger instance
     log.info("process took " + elapsedTime / 1000 + " seconds");
     
    • Constructor Summary

      Constructors 
      Constructor Description
      StopWatch​(java.lang.String text)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void pause()  
      void restart()  
      long stop()
      Method stop
      java.lang.String stop​(java.text.DecimalFormat df)  
      • Methods inherited from class java.lang.Object

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

      • StopWatch

        public StopWatch​(java.lang.String text)
        Parameters:
        text - An optional name for this StopWatch instance
    • Method Detail

      • stop

        public long stop()
        Method stop
      • stop

        public java.lang.String stop​(java.text.DecimalFormat df)
      • pause

        public void pause()
      • restart

        public void restart()