Class TimeMeasure
java.lang.Object
com.github.hypfvieh.util.TimeMeasure
Utility class for time measurements.
Instances may be reset for reuse.
Instances may be reset for reuse.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDuration(double _millis) Converts a fractional milliseconds duration to a user-friendly formatted string e.g. for logging.longGets the elapsed time in milliseconds and resets the instance.Returns the elapsed time as a formatted, user-friendly string.longGets the elapsed time in milliseconds.doubleGets the elapsed time in fractional minutes.longGets the elapsed time in nanoseconds.longGets the elapsed time in seconds.reset()Resets the start time to current time.toString()Returns the elapsed time in milliseconds formatted as string by callinggetElapsedFormatted().
-
Constructor Details
-
TimeMeasure
public TimeMeasure()Default constructor with start time equals current time.
-
-
Method Details
-
reset
-
getElapsedMillis
public long getElapsedMillis()Gets the elapsed time in milliseconds.- Returns:
- elapsed time in milliseconds
-
getElapsedNanos
public long getElapsedNanos()Gets the elapsed time in nanoseconds.- Returns:
- elapsed time in nanoseconds
-
getElapsedSeconds
public long getElapsedSeconds()Gets the elapsed time in seconds.- Returns:
- elapsed time in seconds
-
getElapsedMinutes
public double getElapsedMinutes()Gets the elapsed time in fractional minutes.- Returns:
- elapsed time in minutes
-
getElapsedFormatted
Returns the elapsed time as a formatted, user-friendly string.- Returns:
- formatted string
-
getElapsedAndReset
public long getElapsedAndReset()Gets the elapsed time in milliseconds and resets the instance.- Returns:
- elapsed time
-
formatDuration
Converts a fractional milliseconds duration to a user-friendly formatted string e.g. for logging.- Parameters:
_millis- elapsed time in milliseconds- Returns:
- formatted string
-
toString
Returns the elapsed time in milliseconds formatted as string by callinggetElapsedFormatted().
-