Package org.bitcoinj.base.internal
Class Stopwatch
- java.lang.Object
-
- org.bitcoinj.base.internal.Stopwatch
-
- All Implemented Interfaces:
java.time.temporal.TemporalAmount
public class Stopwatch extends java.lang.Object implements java.time.temporal.TemporalAmountA tool for measuring time, mainly for log messages. Note this class isn't affected by the mock clock ofTimeUtils.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.temporal.TemporaladdTo(java.time.temporal.Temporal temporal)java.time.Durationelapsed()Gets the elapsed time on the watch.longget(java.time.temporal.TemporalUnit temporalUnit)java.util.List<java.time.temporal.TemporalUnit>getUnits()booleanisRunning()Returns true if the stopwatch is running.static Stopwatchstart()Start a newly created stopwatch.Stopwatchstop()Stops the stopwatch, if it is running.java.time.temporal.TemporalsubtractFrom(java.time.temporal.Temporal temporal)java.lang.StringtoString()
-
-
-
Method Detail
-
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 java.time.Duration elapsed()
Gets the elapsed time on the watch. This doesn't stop the watch.- Returns:
- elapsed time
-
get
public long get(java.time.temporal.TemporalUnit temporalUnit)
- Specified by:
getin interfacejava.time.temporal.TemporalAmount
-
getUnits
public java.util.List<java.time.temporal.TemporalUnit> getUnits()
- Specified by:
getUnitsin interfacejava.time.temporal.TemporalAmount
-
addTo
public java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)
- Specified by:
addToin interfacejava.time.temporal.TemporalAmount
-
subtractFrom
public java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)
- Specified by:
subtractFromin interfacejava.time.temporal.TemporalAmount
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-