Package org.esa.snap.core.util
Class StopWatch
java.lang.Object
org.esa.snap.core.util.StopWatch
The
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);
}
...
- Version:
- $Revision$ $Date$
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongGets the user defined end time in milliseconds (the one that was set when thestop()method was called).longGets the user defined start time in milliseconds (the one that was set when thestart()method was called).longGets the elapsed time between start time and end time.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 StringgetTimeString(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.voidstart()Defines the start time by callingjava.lang.System.currentTimeMillis().voidstop()Defines the end time by callingjava.lang.System.currentTimeMillis().voidstopAndTrace(String label) toString()Return a string representation of the elapsed time by callinggetTimeDiffString().void
-
Constructor Details
-
StopWatch
public StopWatch()Construct a new stop watch object. The constructor simply callsstart().
-
-
Method Details
-
start
public void start()Defines the start time by callingjava.lang.System.currentTimeMillis(). -
stop
public void stop()Defines the end time by callingjava.lang.System.currentTimeMillis(). -
getStartTime
public long getStartTime()Gets the user defined start time in milliseconds (the one that was set when thestart()method was called). -
getEndTime
public long getEndTime()Gets the user defined end time in milliseconds (the one that was set when thestop()method was called). -
getTimeDiff
public long getTimeDiff()Gets the elapsed time between start time and end time. -
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.- Returns:
- the elapsed time as a string
-
getTimeString
Utility method that converts a given time in milliseconds in the format "hours:minutes:seconds", with seconds given as a decimal floating point number.- Parameters:
millis- the time in milliseconds- Returns:
- the time as a string
-
toString
Return a string representation of the elapsed time by callinggetTimeDiffString(). -
stopAndTrace
-
trace
-