Class Stopwatch

java.lang.Object
org.bitcoinj.base.internal.Stopwatch
All Implemented Interfaces:
TemporalAmount

public class Stopwatch extends Object implements TemporalAmount
A tool for measuring time, mainly for log messages. Note this class isn't affected by the mock clock of TimeUtils.
  • Method Details

    • start

      public static Stopwatch start()
      Start a newly created stopwatch.
      Returns:
      the stopwatch that was just started
    • stop

      public Stopwatch stop()
      Stops the stopwatch, if it is running.
      Returns:
      the stopwatch that is stopped
    • isRunning

      public boolean isRunning()
      Returns true if the stopwatch is running.
      Returns:
      true if the stopwatch is running, false otherwise
    • elapsed

      public Duration elapsed()
      Gets the elapsed time on the watch. This doesn't stop the watch.
      Returns:
      elapsed time
    • get

      public long get(TemporalUnit temporalUnit)
      Specified by:
      get in interface TemporalAmount
    • getUnits

      public List<TemporalUnit> getUnits()
      Specified by:
      getUnits in interface TemporalAmount
    • addTo

      public Temporal addTo(Temporal temporal)
      Specified by:
      addTo in interface TemporalAmount
    • subtractFrom

      public Temporal subtractFrom(Temporal temporal)
      Specified by:
      subtractFrom in interface TemporalAmount
    • toString

      public String toString()
      Overrides:
      toString in class Object