xmlBlaster 2.2.0 API

org.xmlBlaster.util
Class StopWatch

java.lang.Object
  extended by org.xmlBlaster.util.StopWatch

public class StopWatch
extends java.lang.Object

Measure the elapsed time.

Use this helper class if you want to measure elapsed time in some code fragment

Example:

 

Author:
Marcel Ruff

Field Summary
private  long startTime
           
private  long stopTime
           
 
Constructor Summary
StopWatch()
           
 
Method Summary
 long elapsed()
          Return the elapsed milliseconds since creation or since the last restart().
static void main(java.lang.String[] args)
          Only for testing.
 java.lang.String nice()
          Returns a nice string with elapsed time.
 java.lang.String nice(boolean restart)
          Returns a nice string with elapsed time.
 java.lang.String nice(long iterations)
          Returns a nice string with elapsed time per iteration.
 void restart()
          Reset and start the stop watch for a new measurement cycle.
 void stop()
          Stop the watch
 java.lang.String toString()
          Nicely formatted output containing elapsed time since Construction or since last restart().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startTime

private long startTime

stopTime

private long stopTime
Constructor Detail

StopWatch

public StopWatch()
Method Detail

elapsed

public final long elapsed()
Return the elapsed milliseconds since creation or since the last restart().

Returns:
elapsed Milliseconds since creation or restart()

stop

public final void stop()
Stop the watch


nice

public final java.lang.String nice()
Returns a nice string with elapsed time. Resets the stop watch.

Returns:
The elapsed time in a nice formatted string

nice

public final java.lang.String nice(long iterations)
Returns a nice string with elapsed time per iteration. Stops the StopWatch, but does not reset the stop watch.

Returns:
The elapsed time in a nice formatted string

nice

public final java.lang.String nice(boolean restart)
Returns a nice string with elapsed time.

Parameters:
restart - true: Resets the stop watch.
Returns:
The elapsed time in a nice formatted string

toString

public final java.lang.String toString()
Nicely formatted output containing elapsed time since Construction or since last restart().

Overrides:
toString in class java.lang.Object
Returns:
The elapsed time in a nice formatted string

restart

public final void restart()
Reset and start the stop watch for a new measurement cycle.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Only for testing.

Invoke: java org.xmlBlaster.util.StopWatch

Throws:
java.lang.Exception

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.