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)
TimeInstrument
start
in interface TimeInstrument
public java.lang.String getName()
TimeInstrument
getName
in interface TimeInstrument
public TimeInstrument stop()
TimeInstrument
stop
in interface TimeInstrument
public StopWatch stop(long stopTime)
public java.lang.String toString()
toString
in class java.lang.Object
public final long elapsedTime()
TimeInstrument
elapsedTime
in interface TimeInstrument
public TimeInstrumentStatus getStatus()
getStatus
in interface TimeInstrument
public void print()
TimeInstrument
print
in interface TimeInstrument
public void log()
TimeInstrument
StopWatch
instances cannot log while Profiler
instances can.log
in interface TimeInstrument