|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.util.Stopwatch
public class Stopwatch
Stopwatch is a convenient implementation to bench just about anything. Todo: provide support for internationalization
| Constructor Summary | |
|---|---|
Stopwatch()
initializes a running Stopwatch starting now |
|
Stopwatch(boolean isRunning)
If the boolean parameter is true, this call is equivalent to the default constructor; if the parameter is false, the StopWach will be initialized but is halted with no elapsed time so far. |
|
Stopwatch(java.util.Date time)
This constructor starts a Stopwatch starting at the given point in time. |
|
Stopwatch(long milliseconds)
This constructor starts a Stopwatch starting at the current time minus the milliseconds given. |
|
Stopwatch(long milliseconds,
boolean isRunning)
|
|
Stopwatch(Stopwatch timer)
This constructor generates a new Stopwatch synchronized with the given timer |
|
| Method Summary | |
|---|---|
java.lang.String |
display()
displays the elapsed time as timeAsStringShort(elapsed()) |
long |
elapsed()
returns the elapsed time in milliseconds |
java.lang.String |
elapsedAsString()
returns a string representing the elapsed time with - if applicable - days, hours, minutes and seconds (down to the milliseconds). |
protected long |
getEnd()
|
protected long |
getHalted()
|
java.util.Date |
getStartDate()
returns the initial start time of the Stopwatch. |
long |
getStartTime()
returns the time this Stopwatch was constructed or when any of the reset() or restart() methods were called last |
boolean |
isPaused()
returns true if Stopwatch is paused. |
boolean |
isRunning()
returns true if Stopwatch is running. |
void |
pause()
pause() stops the timer and maintains the elapsed time; it does nothing if the timer is already paused. |
void |
reset()
reset() will set the start to the current time and set the halted time to zero. |
void |
reset(long milliseconds)
sets the given time as elapsed time; run/pause status remains and halted time is reset |
void |
restart()
restart() reinitializes the timer equivalent to it just being construced with the default constructor (time is running). |
void |
restart(long milliseconds)
restart() reinitializes the timer with the passed milliseconds interpreted as already elapsed time. |
void |
resume()
resume() will reactivate a suspended timer (suspended through either stop() or pause()). |
void |
start()
start() maintains the beginning time and sets the elapsed time to zero (through halted time); time will be running. |
long |
stop()
stop() returns the elapsed time and also performs a reset(). |
void |
synchronize(Stopwatch timer)
synchronize() will make this Stopwatch equivalent to the passed timer |
static java.lang.String |
timeAsString(long milliSecs)
takes milliseconds and converts them into a String using all relevant time measures up to days |
static java.lang.String |
timeAsStringShort(long milliSecs)
takes milliseconds and converts them into a short String. |
java.lang.String |
toString()
returns the elapsed time in a convenient format including elapsedAsString() and tells whether the Stopwatch is currently running or not |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Stopwatch()
public Stopwatch(long milliseconds)
public Stopwatch(java.util.Date time)
public Stopwatch(Stopwatch timer)
public Stopwatch(boolean isRunning)
public Stopwatch(long milliseconds,
boolean isRunning)
| Method Detail |
|---|
public void synchronize(Stopwatch timer)
public long getStartTime()
public java.util.Date getStartDate()
public boolean isPaused()
public boolean isRunning()
public void pause()
public void resume()
public void start()
public long stop()
public void reset()
public void reset(long milliseconds)
public void restart()
public void restart(long milliseconds)
public long elapsed()
public java.lang.String elapsedAsString()
public java.lang.String display()
timeAsStringShort(long)public static java.lang.String timeAsString(long milliSecs)
public static java.lang.String timeAsStringShort(long milliSecs)
h:mm:ss.
public java.lang.String toString()
toString in class java.lang.Objectprotected long getHalted()
protected long getEnd()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||