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 long
getEnd()
Returns the end time.long
Returns the currently elapsed time without stopping the timer, if running.long
Returns the execution time in milliseconds.protected long
getStart()
Returns the start time.boolean
Returns if the timer is currently running.void
start()
Starts the timer.long
stop()
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
-