HelperFunctions.kt has some documentation
This commit is contained in:
parent
234adbf9b5
commit
a8406bbc9a
@ -13,39 +13,24 @@ object HelperFunctions {
|
||||
0
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a progress report for the current step.
|
||||
* Prints a progress report to console showing current step, total steps, elapsed time, and estimated remaining time.
|
||||
*
|
||||
* @param step The current step number.
|
||||
* @param of The total number of steps.
|
||||
* @param dur The duration in milliseconds so far.
|
||||
*
|
||||
* This method prints a progress report to the console in the format:
|
||||
* "Step {step} of {of} ({formattedDuration} complete | ~{remainingTime} remaining)"
|
||||
*
|
||||
* It calculates the estimated remaining time based on the current duration and
|
||||
* number of steps completed vs total steps.
|
||||
*
|
||||
* The output is printed on the same line to dynamically update the progress.
|
||||
* @param step The current step number
|
||||
* @param of The total number of steps
|
||||
* @param dur The elapsed duration so far in milliseconds
|
||||
*/
|
||||
fun report(step: Int, of: Int, dur: Long) {
|
||||
val remaining = (dur / step) * (of - step)
|
||||
print("\rStep $step of $of (${prettyTimeString(dur)} complete\t|\t~${prettyTimeString(remaining)} remaining) ")
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats the given duration in milliseconds into a human readable time string.
|
||||
* Converts a duration in milliseconds to a human-readable string.
|
||||
*
|
||||
* @param durationMillis The duration to format in milliseconds.
|
||||
*
|
||||
* @return A formatted time string showing the duration broken down into hours, minutes, and seconds.
|
||||
*
|
||||
* This converts the duration into hours, minutes, and seconds based on millis per second,
|
||||
* minute, and hour constants. It returns a string in the format "XhYmZs" where X, Y, and Z are
|
||||
* the calculated hours, minutes, and seconds.
|
||||
*
|
||||
* If durationMillis is 0, it returns "No time data yet" instead.
|
||||
* @param durationMillis The duration to convert, in milliseconds
|
||||
* @return A string representation of the duration, in the format XhYmZs
|
||||
*/
|
||||
fun prettyTimeString(durationMillis: Long): String {
|
||||
if (durationMillis == 0L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user