public class StopWatch extends java.lang.Object implements TimeInstrument
TimeInstrument which can be started and stopped
once and only once.| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
name |
private long |
startTime |
(package private) TimeInstrumentStatus |
status |
private long |
stopTime |
| Constructor and Description |
|---|
StopWatch(StopWatch original) |
StopWatch(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
long |
elapsedTime()
Time elapsed between start and stop, in nanoseconds.
|
java.lang.String |
getName()
All time instruments are named entities.
|
TimeInstrumentStatus |
getStatus() |
void |
log()
If the time instrument has an associated logger, then log information about
this time instrument.
|
void |
print()
Print information about this time instrument on the console.
|
void |
start(java.lang.String name)
Start this time instrument.
|
TimeInstrument |
stop()
Stop this time instrument.
|
StopWatch |
stop(long stopTime) |
java.lang.String |
toString() |
private java.lang.String name
private long startTime
private long stopTime
TimeInstrumentStatus status
public StopWatch(java.lang.String name)
StopWatch(StopWatch original)
public void start(java.lang.String name)
TimeInstrumentstart in interface TimeInstrumentpublic java.lang.String getName()
TimeInstrumentgetName in interface TimeInstrumentpublic TimeInstrument stop()
TimeInstrumentstop in interface TimeInstrumentpublic StopWatch stop(long stopTime)
public java.lang.String toString()
toString in class java.lang.Objectpublic final long elapsedTime()
TimeInstrumentelapsedTime in interface TimeInstrumentpublic TimeInstrumentStatus getStatus()
getStatus in interface TimeInstrumentpublic void print()
TimeInstrumentprint in interface TimeInstrumentpublic void log()
TimeInstrumentStopWatch instances cannot log while Profiler
instances can.log in interface TimeInstrument