Class StopWatch

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

public final class StopWatch extends Object
  • Field Details

    • startNanos

      private long startNanos
    • duration

      private long duration
  • Constructor Details

    • StopWatch

      public StopWatch()
      Creates a StopWatch but does not start it
    • StopWatch

      public StopWatch(boolean autoStart)
      Parameters:
      autoStart - whether or not the timer should be started automatically
  • Method Details

    • start

      public void start()
    • stop

      public void stop()
    • getDuration

      public long getDuration(TimeUnit timeUnit)
      Returns the amount of time that the StopWatch was running.
      Parameters:
      timeUnit - the unit for which the duration should be reported
      Returns:
      the duration of the stopwatch in the specified unit
      Throws:
      IllegalStateException - if the StopWatch has not been stopped via stop()
    • getElapsed

      public long getElapsed(TimeUnit timeUnit)
      Returns the amount of time that has elapsed since the timer was started.
      Parameters:
      timeUnit - the unit for which the elapsed time should be computed
      Returns:
      the elapsed time in the specified unit
    • calculateDataRate

      public String calculateDataRate(long bytes)
    • getDuration

      public String getDuration()