- java.lang.Object
-
- com.pervasive.datarush.commons.util.Timer
-
public class Timer extends Object
Duration timer for elapsed wall-clock time. ATimer
provides stop-watch like behavior useful for timing the duration between events.
-
-
Constructor Summary
Constructors Constructor Description Timer()
Create a new timer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getDuration()
Gets the accumulated time elapsed, in milliseconds.long
getEndTime()
Gets the time at which the timer was stopped.long
getStartTime()
Gets the time at which the timer was last started.void
start()
Starts the timer.void
stop()
Stops the timer.String
toString()
-
-
-
Method Detail
-
start
public void start()
Starts the timer. The timer is considered active and measures the time elapsed since callingstart()
.
-
getStartTime
public long getStartTime()
Gets the time at which the timer was last started.- Returns:
- the start time, as milliseconds since epoch
-
getDuration
public long getDuration()
Gets the accumulated time elapsed, in milliseconds. If the timer is active, this is the time elapsed since callingstart()
. If it is inactive, this is the amount of time which passed between thestart()
andstop()
calls.- Returns:
- the total elapsed time, in milliseconds
-
getEndTime
public long getEndTime()
Gets the time at which the timer was stopped.- Returns:
- the end time, as milliseconds since epoch. If
the timer is still active then
Long.MIN_VALUE
.
-
stop
public void stop()
Stops the timer. If active, the timer becomes inactive and ceases to accumulate elapsed time. Until restarted, the reported duration is the interval of time between the call tostop()
and the previous call tostart()
.
-
-