org.rosuda.util
Class Stopwatch

java.lang.Object
  extended by org.rosuda.util.Stopwatch

public class Stopwatch
extends java.lang.Object

very simple profile class to measure time differences and do some basic profiling

Version:
$Id: Stopwatch.java 454 2003-07-30 23:03:55Z starsoft $

Constructor Summary
Stopwatch()
          creates a new Stopwatch with current time as start time (i.e.
Stopwatch(boolean beQuiet)
          same as Stopwatch() except that the user can enable/disable verbosity of the profiling
 
Method Summary
 long elapsed()
          returns time elapsed since start without stopping the clock
 long last()
          returns elapsed time between last start and stop (even if new start was issued already) or -1 if not a single complete start/stop sequece exists.
 void profile()
          print profiling information, i.e. do a restart and print the last elapsed time if not in quiet mode
 void profile(java.lang.String s)
          print profiling information, i.e. do a restart and print the last elapsed time if not in quiet mode
 long restart()
          same as issuing stop followed by start except that the time used for both is identical
 long start()
          sets the start time to current time
 long stop()
          marks the stop time and returns the elapsed time since start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stopwatch

public Stopwatch()
creates a new Stopwatch with current time as start time (i.e. start() doesn't have to be called)


Stopwatch

public Stopwatch(boolean beQuiet)
same as Stopwatch() except that the user can enable/disable verbosity of the profiling

Parameters:
beQuiet - if set to true profiling function won't print anyhting to console
Method Detail

stop

public long stop()
marks the stop time and returns the elapsed time since start

Returns:
elapsed time between start and now in ms

start

public long start()
sets the start time to current time

Returns:
the start time in ms (see System.currentTimeMillis())

last

public long last()
returns elapsed time between last start and stop (even if new start was issued already) or -1 if not a single complete start/stop sequece exists.

Returns:
elapsed time between last start and stop

elapsed

public long elapsed()
returns time elapsed since start without stopping the clock

Returns:
elapsed time since start

restart

public long restart()
same as issuing stop followed by start except that the time used for both is identical

Returns:
elapsed time between last start and now

profile

public void profile()
print profiling information, i.e. do a restart and print the last elapsed time if not in quiet mode


profile

public void profile(java.lang.String s)
print profiling information, i.e. do a restart and print the last elapsed time if not in quiet mode