Package org.jboss.as.server
Class ElapsedTime
- java.lang.Object
-
- org.jboss.as.server.ElapsedTime
-
public final class ElapsedTime extends Object
Tracks elapsed time since either JVM start or a moment of initialization. The start point for the calculation can be 'reset', allowing the calculation provided by an instance to account for a conceptual 'restart'.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ElapsedTimecheckpoint()Create an ElapsedTime that tracks elapsed time from the current time, but whose starting point will automatically beresetif this object is reset.longgetElapsedTime()Get the elapsed time in milliseconds since this tracker's start point.longgetStartTime()Gets the tracker's start point.voidreset()Reset this tracker to begin tracking from theJVM start time.static ElapsedTimestartingFromJvmStart()Creates a tracker that tracks elapsed time since JVM start.static ElapsedTimestartingFromNow()Creates a tracker that tracks elapsed time since the invocation of this method.
-
-
-
Method Detail
-
startingFromJvmStart
public static ElapsedTime startingFromJvmStart()
Creates a tracker that tracks elapsed time since JVM start.- Returns:
- the tracker. Will not return
null.
-
startingFromNow
public static ElapsedTime startingFromNow()
Creates a tracker that tracks elapsed time since the invocation of this method.- Returns:
- the tracker. Will not return
null.
-
getStartTime
public long getStartTime()
Gets the tracker's start point.- Returns:
- the start point for this tracker, in milliseconds since the epoch.
-
getElapsedTime
public long getElapsedTime()
Get the elapsed time in milliseconds since this tracker's start point.- Returns:
- the elapsed time
-
reset
public void reset()
Reset this tracker to begin tracking from theJVM start time. Any ElapsedTime objects that were returned from this object'scheckpoint()method will also be reset. Meant for cases where the 'origin' moment may have changed and this tracker should be updated accordingly -- for example, in a 'restored' JVM that supports some form of checkpoint and restore behavior.
-
checkpoint
public ElapsedTime checkpoint()
Create an ElapsedTime that tracks elapsed time from the current time, but whose starting point will automatically beresetif this object is reset.
-
-