public class StopWatch
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StopWatch.Resolution |
| Constructor and Description |
|---|
StopWatch()
Create a new stop watch (with milliseconds resolution).
|
StopWatch(StopWatch.Resolution resolution)
Create a new stop watch.
|
| Modifier and Type | Method and Description |
|---|---|
long |
elapsedMillis()
Returns the elapsed time of this stop watch.
|
long |
elapsedNanos()
Returns the elapsed time of this stop watch.
|
static java.lang.String |
formatMillis(long millis)
Formats an elapsed time given in milliseconds
|
static java.lang.String |
formatNanos(long nanos)
Formats an elapsed time given in nanoseconds
|
static StopWatch |
millis()
Create a new stop watch (with milliseconds resolution).
|
static StopWatch |
nanos()
Create a new stop watch (with nanoseconds resolution).
|
long |
splitTime()
Returns the split time
|
StopWatch |
start()
Restart the stop watch setting the start time to now
|
StopWatch |
stop()
Stops the stop watch setting the elapsed time to now - start time.
|
java.lang.String |
toString() |
public StopWatch()
public StopWatch(StopWatch.Resolution resolution)
resolution - the resolutionpublic static StopWatch millis()
public static StopWatch nanos()
public StopWatch start()
public StopWatch stop()
Stops the stop watch setting the elapsed time to now - start time.
A stop watch may be stopped multiple times each time setting the elapsed time to now - start time.
public long elapsedMillis()
public long elapsedNanos()
public long splitTime()
public java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.String formatMillis(long millis)
Formats chosen
millis - a duration in millisecondspublic static java.lang.String formatNanos(long nanos)
Formats chosen
nanos - a duration in nanoseconds