helix.graph.util
Class StopWatch

java.lang.Object
  extended by helix.graph.util.StopWatch

public class StopWatch
extends Object

a better stopwatch : you don't need to stop it all the time.
here are valid sequences :
start stop get start start get ... get stop start get ... reset ... get stop This stopwatch also has some additional logging facilities.


Constructor Summary
StopWatch()
          Constructor : default / use Logger.global as logger
StopWatch(Logger logger)
          Constructor : default / use Logger.global as logger
 
Method Summary
 long get()
          Express the "reading" on the stopwatch as a numeric type.
 void log()
          log current value on Logger at INFO level
 void log(Level level, String header)
          log current value on Logger
 void log(String header)
          log current value on Logger at INFO level
 void reset()
          Reset the stopwatch, whatever its state
 void start()
          Start the stopwatch - with reset same as start(true)
 void start(boolean reset)
          Start the stopwatch.
 void stop()
          Stop the stopwatch.
 String toString()
          override: express the "reading" on the stopwatch as a String
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch()
Constructor : default / use Logger.global as logger


StopWatch

public StopWatch(Logger logger)
Constructor : default / use Logger.global as logger

Method Detail

start

public void start(boolean reset)
Start the stopwatch.

Parameters:
reset - reset stopwatch
Throws:
IllegalStateException - if the stopwatch is already running or started for the first time with reset==false

start

public void start()
Start the stopwatch - with reset same as start(true)


stop

public void stop()
Stop the stopwatch.

Throws:
IllegalStateException - if the stopwatch is not already running.

reset

public void reset()
Reset the stopwatch, whatever its state


get

public long get()
Express the "reading" on the stopwatch as a numeric type. note: you don't need to stop the stopwatch to read its value


toString

public String toString()
override: express the "reading" on the stopwatch as a String

Overrides:
toString in class Object

log

public void log(Level level,
                String header)
log current value on Logger


log

public void log(String header)
log current value on Logger at INFO level


log

public void log()
log current value on Logger at INFO level