ch.aplu.util
Class HiResTimer

java.lang.Object
  |
  +--ch.aplu.util.BaseTimer
        |
        +--ch.aplu.util.HiResTimer

public class HiResTimer
extends BaseTimer

Class to define a timer with high resolution (based on J3DTimer). (Resolution normally better than 1 microseconds.) The timer's accuracy is not garanteed because of multitasking/multithreading of operating system and Java. (All methods (except constructors) call yield() of the current thread unless disabled by special constructor.)


Constructor Summary
HiResTimer()
          Construct a HiResTimer object and set its time to zero.
HiResTimer(boolean autostart)
          Same as HiResTimer(), but the timer starts immediately if autostart is true.
HiResTimer(boolean autostart, boolean yield)
          Same as HiResTimer(autostart), but most methods calls Thread.yield() automatically, if yield is true.
 
Method Summary
static long getResolution()
          Return the time resolution of the timer ( in nanoseconds )
 
Methods inherited from class ch.aplu.util.BaseTimer
getTime, isRunning, reset, resume, start, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HiResTimer

public HiResTimer()
Construct a HiResTimer object and set its time to zero. The timer must be started by calling start().


HiResTimer

public HiResTimer(boolean autostart)
Same as HiResTimer(), but the timer starts immediately if autostart is true.


HiResTimer

public HiResTimer(boolean autostart,
                  boolean yield)
Same as HiResTimer(autostart), but most methods calls Thread.yield() automatically, if yield is true. This may give a much better time response when using loops with an empty body like

while ( watch.isRunning() ) {}.

Method Detail

getResolution

public static long getResolution()
Return the time resolution of the timer ( in nanoseconds )