harpoon.Util
Class Timer

java.lang.Object
  extended by harpoon.Util.Timer

public class Timer
extends Object

Timer keeps track of how much time accumulates between successive calls to start and stop. This is useful when profiling the compiler. Timer t = new Timer(); for (int i=0; i<10; i++) { bar(); t.start(); foo(); t.stop(); } System.out.println(t.timeElapsed()); This prints the total time spent in foo in milliseconds.


Constructor Summary
Timer()
          Create a new Timer and initialize timeElapsed to 0.
 
Method Summary
 void freshStart()
           
 boolean running()
          Ask if the timer is currently running.
 void start()
          Start the timer running.
 void stop()
          Stop the timer.
 long timeElapsed()
          Return the cumulative amount of time elapsed between starts and stops in milliseconds.
 String toString()
          Return a string representing the current state of the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Create a new Timer and initialize timeElapsed to 0.

Method Detail

running

public boolean running()
Ask if the timer is currently running.


start

public void start()
Start the timer running.


stop

public void stop()
Stop the timer.


freshStart

public void freshStart()

timeElapsed

public long timeElapsed()
Return the cumulative amount of time elapsed between starts and stops in milliseconds.


toString

public String toString()
Return a string representing the current state of the timer.

Overrides:
toString in class Object