Reduce verbosity of CleanupSession debug logs.
Currently we wait up to 10s for this operation to complete. Replacing the two log lines with three, lets us halve the number of logs printed every 10ms, but always print exactly one log line each iteration of the loop. Rather than: ``` 02-10 19:58:48.880 3140 3140 D CleanupSession: Wait for all Realm instance to be closed (29 - 0) 02-10 19:58:48.880 3140 3140 D CleanupSession: Waiting 10ms 02-10 19:58:48.890 3140 3140 D CleanupSession: Wait for all Realm instance to be closed (29 - 0) 02-10 19:58:48.890 3140 3140 D CleanupSession: Waiting 10ms 02-10 19:58:48.900 3140 3140 D CleanupSession: Wait for all Realm instance to be closed (29 - 0) 02-10 19:58:48.900 3140 3140 D CleanupSession: Waiting 10ms 02-10 19:58:48.910 3140 3140 D CleanupSession: Wait for all Realm instance to be closed (29 - 0) 02-10 19:58:48.910 3140 3140 D CleanupSession: Waiting 10ms 02-10 19:58:48.920 3140 3140 D CleanupSession: Wait for all Realm instance to be closed (0 - 0) ``` We'll print: ``` 02-10 19:58:48.880 3140 3140 D CleanupSession: Waiting 10ms for all Realm instance to be closed (29 - 0) 02-10 19:58:48.890 3140 3140 D CleanupSession: Waiting 10ms for all Realm instance to be closed (29 - 0) 02-10 19:58:48.900 3140 3140 D CleanupSession: Waiting 10ms for all Realm instance to be closed (29 - 0) 02-10 19:58:48.910 3140 3140 D CleanupSession: Waiting 10ms for all Realm instance to be closed (29 - 0) 02-10 19:58:48.920 3140 3140 D CleanupSession: Finished waiting for all Realm instance to be closed (0 - 0) ``` The above example took 40ms to finish and saved 4 log lines; you can see how it adds up if you take 10000ms to finish.
This commit is contained in:
parent
fd89acc112
commit
f44f37629a
|
@ -94,12 +94,12 @@ internal class CleanupSession @Inject constructor(
|
||||||
do {
|
do {
|
||||||
val sessionRealmCount = Realm.getGlobalInstanceCount(realmSessionConfiguration)
|
val sessionRealmCount = Realm.getGlobalInstanceCount(realmSessionConfiguration)
|
||||||
val cryptoRealmCount = Realm.getGlobalInstanceCount(realmCryptoConfiguration)
|
val cryptoRealmCount = Realm.getGlobalInstanceCount(realmCryptoConfiguration)
|
||||||
Timber.d("Wait for all Realm instance to be closed ($sessionRealmCount - $cryptoRealmCount)")
|
|
||||||
if (sessionRealmCount > 0 || cryptoRealmCount > 0) {
|
if (sessionRealmCount > 0 || cryptoRealmCount > 0) {
|
||||||
Timber.d("Waiting ${TIME_TO_WAIT_MILLIS}ms")
|
Timber.d("Waiting ${TIME_TO_WAIT_MILLIS}ms for all Realm instance to be closed ($sessionRealmCount - $cryptoRealmCount)")
|
||||||
delay(TIME_TO_WAIT_MILLIS)
|
delay(TIME_TO_WAIT_MILLIS)
|
||||||
timeToWaitMillis -= TIME_TO_WAIT_MILLIS
|
timeToWaitMillis -= TIME_TO_WAIT_MILLIS
|
||||||
} else {
|
} else {
|
||||||
|
Timber.d("Finished waiting for all Realm instance to be closed ($sessionRealmCount - $cryptoRealmCount)")
|
||||||
timeToWaitMillis = 0
|
timeToWaitMillis = 0
|
||||||
}
|
}
|
||||||
} while (timeToWaitMillis > 0)
|
} while (timeToWaitMillis > 0)
|
||||||
|
|
Loading…
Reference in New Issue