Class Timer

java.lang.Object
jflex.performance.Timer

public class Timer extends Object
Very simple timer for code generation time statistics.

Not very exact, measures user time, not processor time.

Version:
JFlex 1.8.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    private long
     
    private long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new timer that starts immediately.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Return the number of milliseconds the timer has been running.
    void
    Start the timer.
    void
    Stop the timer.
    Return a string representation of the timer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • startTime

      private long startTime
    • stopTime

      private long stopTime
    • running

      private boolean running
  • Constructor Details

    • Timer

      public Timer()
      Construct a new timer that starts immediately.
  • Method Details

    • start

      public void start()
      Start the timer. If it is already running, the old start time is lost.
    • stop

      public void stop()
      Stop the timer.
    • diff

      public long diff()
      Return the number of milliseconds the timer has been running.

      (up till now, if it still runs, up to the stop time if it has been stopped)

      Returns:
      a long.
    • toString

      public String toString()
      Return a string representation of the timer.
      Overrides:
      toString in class Object
      Returns:
      a string displaying the diff-time in readable format (h m s ms)
      See Also: