jautil
Class JATimer

java.lang.Object
  extended by jautil.JATimer

public class JATimer
extends java.lang.Object

A JATimer provides (real-) time measurement, using the Java 5 nano-second System timer (whose resolution may well be less fine- grained than 1 ns.), to provide interval measures expressed in milliseconds (as values of type float). Each timer also has facilities for the display of real-time values.


Constructor Summary
JATimer()
          Constructs a new timer and sets its interval start value to the current system time.
 
Method Summary
 float getAndShowRelativeTimeMS(long tbase, java.lang.String tag)
          As for showRelativeTimeMS(long, String), but this method also returns the displayed value.
 float getAndShowTimeMS(java.lang.String tag)
          As for showTimeMS(String), but this method also returns the displayed value.
 float getRelativeTimeMS(long tbase)
          Returns the duration of the interval defined by the given base value (measured in nanoseconds) and the present, the duration being measured in milliseconds.
 float getTimeDeltaMS(long tm0, long tm1)
          Returns the duration of the interval defined by the given pair of time values: the result is measured in milliseconds, while the inputs are measured in nanoseconds.
 float getTimeMS()
          Returns the duration of the interval defined by this timer's "start" value and the present, the duration being measured in milliseconds.
 long getTimeNow()
          Returns the current system time in nanoseconds (so this is just a wrapper for System.nanotime().
 void setDisplayDisabled(boolean da)
          Sets the value of this timer's display-disabled flag: request to display a time message will be ignored if (but only if) this flag is true.
 void showGivenTimeMS(float tms, java.lang.String tag)
          Displays the given (millisecond) time value, prefixed with the given tag string, as a line on standard output -- but does nothing if display is currently disabled on this timer.
 void showRelativeTimeMS(long tbase, java.lang.String tag)
          Displays the duration (in milliseconds) of the interval defined by this timer's "start" time and the present -- that is, the value given by getRelativeTimeMS(long) -- prefixed with the given tag string, as a line on standard output.
 void showTimeMS(java.lang.String tag)
          Displays the duration (in milliseconds) of the current interval -- that is, the value given by getTimeMS() -- prefixed with the given tag string, as a line on standard output.
 void showTimeMSAndRestart(java.lang.String tag)
          Displays the duration (in milliseconds) of the current interval -- that is, the value given by getTimeMS() -- prefixed with the given tag string, as a line on standard output; also re-starts this timer before returning.
 void start()
          Sets this timer's interval start value to the current system time.
 long startAndGet()
          Performs a "start" operation on this timer, and returns the interval start value (in nanoseconds) defined by that operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JATimer

public JATimer()
Constructs a new timer and sets its interval start value to the current system time.

Method Detail

setDisplayDisabled

public void setDisplayDisabled(boolean da)
Sets the value of this timer's display-disabled flag: request to display a time message will be ignored if (but only if) this flag is true.


start

public void start()
Sets this timer's interval start value to the current system time.


getTimeNow

public long getTimeNow()
Returns the current system time in nanoseconds (so this is just a wrapper for System.nanotime().


startAndGet

public long startAndGet()
Performs a "start" operation on this timer, and returns the interval start value (in nanoseconds) defined by that operation.


getTimeDeltaMS

public float getTimeDeltaMS(long tm0,
                            long tm1)
Returns the duration of the interval defined by the given pair of time values: the result is measured in milliseconds, while the inputs are measured in nanoseconds.


getTimeMS

public float getTimeMS()
Returns the duration of the interval defined by this timer's "start" value and the present, the duration being measured in milliseconds.


getRelativeTimeMS

public float getRelativeTimeMS(long tbase)
Returns the duration of the interval defined by the given base value (measured in nanoseconds) and the present, the duration being measured in milliseconds.


showGivenTimeMS

public void showGivenTimeMS(float tms,
                            java.lang.String tag)
Displays the given (millisecond) time value, prefixed with the given tag string, as a line on standard output -- but does nothing if display is currently disabled on this timer.


showTimeMS

public void showTimeMS(java.lang.String tag)
Displays the duration (in milliseconds) of the current interval -- that is, the value given by getTimeMS() -- prefixed with the given tag string, as a line on standard output.


showTimeMSAndRestart

public void showTimeMSAndRestart(java.lang.String tag)
Displays the duration (in milliseconds) of the current interval -- that is, the value given by getTimeMS() -- prefixed with the given tag string, as a line on standard output; also re-starts this timer before returning.


showRelativeTimeMS

public void showRelativeTimeMS(long tbase,
                               java.lang.String tag)
Displays the duration (in milliseconds) of the interval defined by this timer's "start" time and the present -- that is, the value given by getRelativeTimeMS(long) -- prefixed with the given tag string, as a line on standard output.


getAndShowTimeMS

public float getAndShowTimeMS(java.lang.String tag)
As for showTimeMS(String), but this method also returns the displayed value.


getAndShowRelativeTimeMS

public float getAndShowRelativeTimeMS(long tbase,
                                      java.lang.String tag)
As for showRelativeTimeMS(long, String), but this method also returns the displayed value.