JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.alsUtility
Class Timer

java.lang.Object
  extended bygov.nasa.alsUtility.Timer
All Implemented Interfaces:
java.io.Serializable

public class Timer
extends java.lang.Object
implements java.io.Serializable

time things using wallclock time. Will also keep track of time allocated for a task and let you know when time is up.

See Also:
Serialized Form

Field Summary
protected  long lastStart
           
protected  boolean running
           
protected  long timeAllocated
           
protected  long timeUsed
           
 
Constructor Summary
Timer()
           
Timer(long t)
           
 
Method Summary
 boolean isDone()
          has the allocated time been used?
 void reset()
          resets the timer and stops
 void reset(long t)
          resets the timer and stops
 void start()
          starts the clock
 void stop()
          stops the clock and remembers the time used
static void test(java.lang.String[] arguments)
           
 long timeAvailable()
          how much allocated time is still available?
 long timeElapsed()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timeAllocated

protected long timeAllocated

timeUsed

protected long timeUsed

lastStart

protected long lastStart

running

protected boolean running
Constructor Detail

Timer

public Timer()

Timer

public Timer(long t)
Parameters:
t - sets the time allocated
Method Detail

toString

public java.lang.String toString()

reset

public void reset(long t)
resets the timer and stops

Parameters:
t - sets the time allocated

reset

public void reset()
resets the timer and stops


stop

public void stop()
stops the clock and remembers the time used


start

public void start()
starts the clock


isDone

public boolean isDone()
has the allocated time been used?


timeElapsed

public long timeElapsed()

timeAvailable

public long timeAvailable()
how much allocated time is still available?


test

public static void test(java.lang.String[] arguments)

JavaGenes, NASA Ames. Written largely by Al Globus