logging the room import time taken
This commit is contained in:
parent
38dec9c802
commit
ef2a2c5624
|
@ -1,5 +1,9 @@
|
|||
package app.dapk.st.core
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onCompletion
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
|
||||
enum class AppLogTag(val key: String) {
|
||||
NOTIFICATION("notification"),
|
||||
PERFORMANCE("performance"),
|
||||
|
@ -26,3 +30,13 @@ suspend fun <T> logP(area: String, block: suspend () -> T): T {
|
|||
log(AppLogTag.PERFORMANCE, "$area: took $timeTaken ms")
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Flow<T>.logP(area: String): Flow<T> {
|
||||
var start = -1L
|
||||
return this
|
||||
.onStart { start = System.currentTimeMillis() }
|
||||
.onCompletion {
|
||||
val timeTaken = System.currentTimeMillis() - start
|
||||
log(AppLogTag.PERFORMANCE, "$area: took $timeTaken ms")
|
||||
}
|
||||
}
|
|
@ -50,12 +50,10 @@ internal class DefaultCryptoService(
|
|||
}
|
||||
|
||||
override suspend fun InputStream.importRoomKeys(password: String): Flow<ImportResult> {
|
||||
return logP("import room keys") {
|
||||
with(roomKeyImporter) {
|
||||
importRoomKeys(password) {
|
||||
importRoomKeys(it)
|
||||
}
|
||||
}
|
||||
return with(roomKeyImporter) {
|
||||
importRoomKeys(password) {
|
||||
importRoomKeys(it)
|
||||
}.logP("import room keys")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ internal class OlmCrypto(
|
|||
) {
|
||||
|
||||
suspend fun importRoomKeys(keys: List<SharedRoomKey>) {
|
||||
logger.crypto("import room keys : ${keys.size}")
|
||||
olm.import(keys)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue