Class StopWatch

java.lang.Object
org.apache.camel.util.StopWatch

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

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

  • Constructor Details

    • StopWatch

      public StopWatch()
      Starts the stop watch
    • StopWatch

      public StopWatch(long timeMillis)
      Starts the stop watch from the given timestamp
    • StopWatch

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

    • restart

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

      public boolean isStarted()
      Whether the watch is started
    • taken

      public long taken()
      Returns the time taken in millis.
      Returns:
      time in millis, or 0 if not started yet.
    • takenAndRestart

      public long takenAndRestart()
      Returns the time taken in millis and restarts the timer.
      Returns:
      time in millis, or 0 if not started yet.