public class StopWatch extends Object
StopWatch
class is a (very) simple utility class that allows to measure the time passed between two
user defined events.
Here is an example:
... private final StopWatch stopWatch = new StopWatch(); ... void doATimeConsumingThing() { stopWatch.start(); ... stopWatch.end(); Debug.trace("Time needed: " + stopWatch); } ...
Constructor and Description |
---|
StopWatch()
Construct a new stop watch object.
|
Modifier and Type | Method and Description |
---|---|
long |
getEndTime()
Gets the user defined end time in milliseconds (the one that was set when the
stop() method was
called). |
long |
getStartTime()
Gets the user defined start time in milliseconds (the one that was set when the
start() method was
called). |
long |
getTimeDiff()
Gets the elapsed time between start time and end time.
|
String |
getTimeDiffString()
Returns the elapsed time between start and end as a string in the format "hours:minutes:seconds",
with seconds given as a decimal floating point number.
|
static String |
getTimeString(long millis)
Utility method that converts a given time in milliseconds in the format "hours:minutes:seconds",
with seconds given as a decimal floating point number.
|
void |
start()
Defines the start time by calling
java.lang.System.currentTimeMillis() . |
void |
stop()
Defines the end time by calling
java.lang.System.currentTimeMillis() . |
void |
stopAndTrace(String label) |
String |
toString()
Return a string representation of the elapsed time by calling
getTimeDiffString() . |
void |
trace(String label) |
public StopWatch()
start()
.public void start()
java.lang.System.currentTimeMillis()
.public void stop()
java.lang.System.currentTimeMillis()
.public long getStartTime()
start()
method was
called).public long getEndTime()
stop()
method was
called).public long getTimeDiff()
public String getTimeDiffString()
public static String getTimeString(long millis)
millis
- the time in millisecondspublic String toString()
getTimeDiffString()
.public void stopAndTrace(String label)
public void trace(String label)
Copyright © 2014–2015 European Space Agency (ESA). All rights reserved.