org.wegra.util.stopwatch
Class Stopwatch

java.lang.Object
  extended byorg.wegra.util.stopwatch.Stopwatch

public class Stopwatch
extends java.lang.Object

Simple stopwatch class to measure job taken time.

Author:
wegra (Bok-Youn Lee)

Constructor Summary
Stopwatch()
           
 
Method Summary
static void begin(java.lang.Object target)
          Sets start time with given key.
static void cancel(java.lang.Object key)
          Cancels time measuring.
static void initWatch()
          Initializes Stopwatch.
static long stop(java.lang.Object target)
          Returns taken time and doesn't continue.
static long stop(java.lang.Object target, boolean continuable)
          Returns taken time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stopwatch

public Stopwatch()
Method Detail

begin

public static void begin(java.lang.Object target)
Sets start time with given key. The key will use when get taken time by getTakenTime() method.

Parameters:
target - The key given by client.

stop

public static long stop(java.lang.Object target)
                 throws UnknownTargetException
Returns taken time and doesn't continue. So, if you call this method, you won't be able to get time again with the same key. You can call getTakenTime(Object, boolean) instead.

Parameters:
target - Target to watch.
Throws:
UnknownTargetException - This exception will be thrown when you call this method before begin watching the target.

stop

public static long stop(java.lang.Object target,
                        boolean continuable)
                 throws UnknownTargetException
Returns taken time.

Parameters:
target - Target to watch.
continuable - true if you want to continue watching.
Throws:
UnknownTargetException - This exception will be thrown when you call this method before begin watching the target.

cancel

public static void cancel(java.lang.Object key)
Cancels time measuring. This method does nothing if the key is not in the time table.

Parameters:
key - the key that needs to be canceled.

initWatch

public static void initWatch()
Initializes Stopwatch.