Package be.panako.util
Class StopWatch
java.lang.Object
be.panako.util.StopWatch
StopWatch counts the ticks (ns) passed between initialization and invocation
of ticksPassed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
formattedToString
(double secondsPassed) long
void
start()
Starts or restarts the watch.long
double
timePassed
(TimeUnit unit) Calculates and returns the time passed in the requested unit.toString()
static String
Returns a 24h time string based on an input resource.
-
Constructor Details
-
StopWatch
public StopWatch()Create and start the stop watch.
-
-
Method Details
-
ticksPassed
public long ticksPassed()- Returns:
- The number of ticks passed between initialization and the call to
ticksPassed
. In milliseconds or 10^-3 seconds.
-
nanoTicksPassed
public long nanoTicksPassed()- Returns:
- The number of ticks passed between initialization and the call to
ticksPassed
. In nanoseconds or 10^-9 seconds.
-
timePassed
Calculates and returns the time passed in the requested unit.- Parameters:
unit
- The requested time unit.- Returns:
- The time passed in the requested unit.
-
start
public void start()Starts or restarts the watch. -
toString
-
toTime
Returns a 24h time string based on an input resource. E.g. "20120325-235950" + 25 seconds would return "00:00:15"- Parameters:
inputResource
- The name of the input resource with a date and time part. E.g. "20120325-235950.wav"currentSeconds
- The number of seconds to add to the time part.- Returns:
- E.g. "20120325-235950" + 25 seconds would return "00:00:15"
-
formattedToString
-
formattedToString
-