Skip to content

Commit

Permalink
-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Oct 26, 2023
1 parent 5652807 commit 71d7d8f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/main/java/mediathek/tool/RuntimeStatistics.java

This file was deleted.

37 changes: 37 additions & 0 deletions src/main/java/mediathek/tool/RuntimeStatistics.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package mediathek.tool

import mediathek.tool.FileUtils.humanReadableByteCountBinary
import mediathek.tool.http.MVHttpClient
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import java.time.Duration
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.format.DateTimeFormatter

object RuntimeStatistics {
@JvmField
val startZeit: LocalDateTime = LocalDateTime.now()
val logger: Logger = LogManager.getLogger()

/**
* Output runtime statistics to console and log file
*/
@JvmStatic
fun printRuntimeStatistics() {
val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
val endZeit = LocalDateTime.now()
val runTime = LocalTime.MIN.plusSeconds(Duration.between(startZeit, endZeit).toSeconds())

logger.info(" --> Start: ${formatter.format(startZeit)}")
logger.info(" --> Ende: ${formatter.format(endZeit)}")
logger.info(" --> Laufzeit: ${runTime.hour}h ${runTime.minute}m ${runTime.second}s")
}

@JvmStatic
fun printDataUsageStatistics() {
val byteCounter = MVHttpClient.getInstance().byteCounter
logger.info("Total data sent: ${humanReadableByteCountBinary(byteCounter.totalBytesWritten())}")
logger.info("Total data received: ${humanReadableByteCountBinary(byteCounter.totalBytesRead())}")
}
}

0 comments on commit 71d7d8f

Please sign in to comment.