-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5652807
commit 71d7d8f
Showing
2 changed files
with
37 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())}") | ||
} | ||
} |