mirror of
https://github.com/element-hq/element-android
synced 2024-10-23 19:26:42 +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,
|
internal suspend fun <T> logDuration(message: String,
|
||||||
block: suspend () -> T): T {
|
block: suspend () -> T): T {
|
||||||
|
val runtime = Runtime.getRuntime()
|
||||||
|
runtime.gc()
|
||||||
|
val usedMemInMBStart = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L
|
||||||
|
|
||||||
Timber.v("$message -- BEGIN")
|
Timber.v("$message -- BEGIN")
|
||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
val result = block()
|
val result = block()
|
||||||
val duration = System.currentTimeMillis() - start
|
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
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue