Fine tune task weights + more measure

This commit is contained in:
Valere 2019-07-09 17:42:53 +02:00
parent c9931e3ba3
commit 6cb94dd4d6
1 changed files with 44 additions and 22 deletions

View File

@ -39,40 +39,62 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl
Timber.v("Start handling sync, is InitialSync: $isInitialSync") Timber.v("Start handling sync, is InitialSync: $isInitialSync")
val reporter = initialSyncProgressService.takeIf { isInitialSync } val reporter = initialSyncProgressService.takeIf { isInitialSync }


measureTimeMillis {
if (!cryptoManager.isStarted()) { if (!cryptoManager.isStarted()) {
Timber.v("Should start cryptoManager") Timber.v("Should start cryptoManager")
cryptoManager.start(isInitialSync) cryptoManager.start(isInitialSync)
} }
}.also {
Timber.v("Finish handling start cryptoManager in $it ms")
}
val measure = measureTimeMillis { val measure = measureTimeMillis {
// Handle the to device events before the room ones // Handle the to device events before the room ones
// to ensure to decrypt them properly // to ensure to decrypt them properly
measureTimeMillis {
Timber.v("Handle toDevice") Timber.v("Handle toDevice")
reportSubtask(reporter, R.string.initial_sync_start_importing_account_crypto, 100, 0.2f) { reportSubtask(reporter, R.string.initial_sync_start_importing_account_crypto, 100, 0.1f) {
if (syncResponse.toDevice != null) { if (syncResponse.toDevice != null) {
cryptoSyncHandler.handleToDevice(syncResponse.toDevice, reporter) cryptoSyncHandler.handleToDevice(syncResponse.toDevice, reporter)
} }
} }
}.also {
Timber.v("Finish handling toDevice in $it ms")
}

measureTimeMillis {
Timber.v("Handle rooms") Timber.v("Handle rooms")


reportSubtask(reporter, R.string.initial_sync_start_importing_account_rooms, 100, 0.5f) { reportSubtask(reporter, R.string.initial_sync_start_importing_account_rooms, 100, 0.7f) {
if (syncResponse.rooms != null) { if (syncResponse.rooms != null) {
roomSyncHandler.handle(syncResponse.rooms, reporter) roomSyncHandler.handle(syncResponse.rooms, reporter)
} }
} }
}.also {
Timber.v("Finish handling rooms in $it ms")
}


reportSubtask(reporter, R.string.initial_sync_start_importing_account_groups, 100, 0.2f) {
measureTimeMillis {
reportSubtask(reporter, R.string.initial_sync_start_importing_account_groups, 100, 0.1f) {
Timber.v("Handle groups") Timber.v("Handle groups")
if (syncResponse.groups != null) { if (syncResponse.groups != null) {
groupSyncHandler.handle(syncResponse.groups, reporter) groupSyncHandler.handle(syncResponse.groups, reporter)
} }
} }
}.also {
Timber.v("Finish handling groups in $it ms")
}


measureTimeMillis {
reportSubtask(reporter, R.string.initial_sync_start_importing_account_data, 100, 0.1f) { reportSubtask(reporter, R.string.initial_sync_start_importing_account_data, 100, 0.1f) {
Timber.v("Handle accountData") Timber.v("Handle accountData")
if (syncResponse.accountData != null) { if (syncResponse.accountData != null) {
userAccountDataSyncHandler.handle(syncResponse.accountData) userAccountDataSyncHandler.handle(syncResponse.accountData)
} }
} }
}.also {
Timber.v("Finish handling accountData in $it ms")
}


Timber.v("On sync completed") Timber.v("On sync completed")
cryptoSyncHandler.onSyncCompleted(syncResponse) cryptoSyncHandler.onSyncCompleted(syncResponse)