mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 04:08:44 +03:00
Try to log RAM usage
This commit is contained in:
parent
c938795576
commit
39e66555f4
1 changed files with 9 additions and 1 deletions
|
@ -20,10 +20,18 @@ import timber.log.Timber
|
|||
|
||||
internal suspend fun <T> logDuration(message: String,
|
||||
block: suspend () -> T): T {
|
||||
val runtime = Runtime.getRuntime()
|
||||
runtime.gc()
|
||||
val usedMemInMBStart = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L
|
||||
|
||||
Timber.v("$message -- BEGIN")
|
||||
val start = System.currentTimeMillis()
|
||||
val result = block()
|
||||
val duration = System.currentTimeMillis() - start
|
||||
Timber.v("$message -- END duration: $duration ms")
|
||||
runtime.gc()
|
||||
val usedMemInMBEnd = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L
|
||||
val usedMemInMBDiff = usedMemInMBEnd - usedMemInMBStart
|
||||
|
||||
Timber.v("$message -- END duration: $duration ms RAM usage: $usedMemInMBDiff MB")
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue