Class TaskTimer
java.lang.Object
org.deltava.util.TaskTimer
- Direct Known Subclasses:
IntervalTaskTimer
A utility class to time operations.
- Since:
- 5.0
- Version:
- 11.1
- Author:
- Luke
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected longgetEnd()Returns the end time.longReturns the currently elapsed time without stopping the timer, if running.longReturns the execution time in milliseconds.protected longgetStart()Returns the start time.booleanReturns if the timer is currently running.voidstart()Starts the timer.longstop()Stops the timer.toString()
-
Field Details
-
_start
protected long _start
-
-
Constructor Details
-
TaskTimer
public TaskTimer()Creates an unstarted timer. -
TaskTimer
public TaskTimer(boolean doStart) Creates and optionally starts a timer.- Parameters:
doStart- TRUE to start the timer, otherwise FALSE
-
-
Method Details
-
start
public void start()Starts the timer. -
getStart
protected long getStart()Returns the start time.- Returns:
- the start time, in nanoseconds
-
getEnd
protected long getEnd()Returns the end time.- Returns:
- the end time, in nanoseconds or zero if running
-
stop
public long stop()Stops the timer.- Returns:
- the execution time in milliseconds
-
getInterval
public long getInterval()Returns the currently elapsed time without stopping the timer, if running.- Returns:
- the execution time in nanoseconds
-
getMillis
public long getMillis()Returns the execution time in milliseconds.- Returns:
- the execution time
-
isRunning
public boolean isRunning()Returns if the timer is currently running.- Returns:
- TRUE if running, otherwise FALSE
-
toString
-