Class TaskTimer

java.lang.Object
org.deltava.util.TaskTimer
Direct Known Subclasses:
IntervalTaskTimer

public class TaskTimer extends Object
A utility class to time operations.
Since:
5.0
Version:
11.1
Author:
Luke
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an unstarted timer.
    TaskTimer(boolean doStart)
    Creates and optionally starts a timer.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected long
    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
    Returns the start time.
    boolean
    Returns if the timer is currently running.
    void
    Starts the timer.
    long
    Stops the timer.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      public String toString()
      Overrides:
      toString in class Object