|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.util.Stopwatch
public class Stopwatch
Stopwatch is a class for performing timing. A Stopwatch starts running immediately upon creation. It can at any time be reset to 0 by calling start() or reset(). The current stopwatch time is shown on the Console with show(); (The latter will not stop or reset the stopwatch; it keeps running) If a series of timeintervals must be measured, it is possible to call showLap() rather than show(). Consecutive showLap() calls show the time between these calls, whereas show() always show the accumulated time. Timing can also be done without Console output, by calling read() instead of show(), or readLap() instead of showLap(). Finally, Stopwatch offers a delay(long) method, which has nothing to do with the stopwatch instances as such. It performs a Thread.sleep(), and catches the annoying exception.
| Field Summary | |
|---|---|
private long |
currenttime
|
private long |
lapstart
|
private String |
name
|
private static int |
NANOSPERMICROSECOND
|
private static int |
NANOSPERMILLISECOND
|
private static int |
NANOSPERSECOND
|
private long |
starttime
|
private static int |
stopwatchcount
|
private static int |
TESTDELAY1
|
private static int |
TESTDELAY2
|
| Constructor Summary | |
|---|---|
Stopwatch()
create a new numbered Stopwatch. |
|
Stopwatch(String name)
create a new named Stopwatch. |
|
| Method Summary | |
|---|---|
static void |
delay(long d)
same as Thread.sleep(), but catches and ignores Exceptions. |
String |
getName()
returns the name of this Stopwatch. |
static void |
main(String[] arg)
|
void |
showMicroseconds()
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in microseconds |
void |
showMicroseconds(String message)
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in microseconds |
void |
showMilliseconds()
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in seconds |
void |
showMilliseconds(String message)
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in milliseconds |
long |
showMillisecondsLap()
read the "lap" time for the stopwatch, relative to reading the last lap time, or relative to starttime if this is the first readLap call. |
void |
showNanoseconds()
|
void |
showNanoseconds(String message)
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in nanoseconds. |
void |
showSeconds()
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in seconds |
void |
showSeconds(String message)
read the current time for the stopwatch, relative to the start time, and show it on the hmi.util.Console, in seconds |
void |
start()
starts/resets the stopwatch, by reading the current system time. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int NANOSPERSECOND
private static final int NANOSPERMILLISECOND
private static final int NANOSPERMICROSECOND
private static final int TESTDELAY1
private static final int TESTDELAY2
private long starttime
private long currenttime
private long lapstart
private String name
private static int stopwatchcount
| Constructor Detail |
|---|
public Stopwatch()
public Stopwatch(String name)
| Method Detail |
|---|
public String getName()
public void start()
public void showSeconds()
public final void showSeconds(String message)
public void showMilliseconds()
public final void showMilliseconds(String message)
public final void showMicroseconds()
public final void showMicroseconds(String message)
public final void showNanoseconds(String message)
public final void showNanoseconds()
public long showMillisecondsLap()
public static void delay(long d)
public static void main(String[] arg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||