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.TemporalAmount
A 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.Temporal
addTo(java.time.temporal.Temporal temporal)
java.time.Duration
elapsed()
Gets the elapsed time on the watch.long
get(java.time.temporal.TemporalUnit temporalUnit)
java.util.List<java.time.temporal.TemporalUnit>
getUnits()
boolean
isRunning()
Returns true if the stopwatch is running.static Stopwatch
start()
Start a newly created stopwatch.Stopwatch
stop()
Stops the stopwatch, if it is running.java.time.temporal.Temporal
subtractFrom(java.time.temporal.Temporal temporal)
java.lang.String
toString()
-
-
-
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:
get
in interfacejava.time.temporal.TemporalAmount
-
getUnits
public java.util.List<java.time.temporal.TemporalUnit> getUnits()
- Specified by:
getUnits
in interfacejava.time.temporal.TemporalAmount
-
addTo
public java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)
- Specified by:
addTo
in interfacejava.time.temporal.TemporalAmount
-
subtractFrom
public java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)
- Specified by:
subtractFrom
in interfacejava.time.temporal.TemporalAmount
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-