Add stopwatch for CallLog loading.
This commit is contained in:
parent
232b84635f
commit
4c9bdd16b0
1 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
package org.thoughtcrime.securesms.calls.log
|
||||
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.paging.PagedDataSource
|
||||
|
||||
class CallLogPagedDataSource(
|
||||
|
@ -8,6 +10,10 @@ class CallLogPagedDataSource(
|
|||
private val repository: CallRepository
|
||||
) : PagedDataSource<CallLogRow.Id, CallLogRow> {
|
||||
|
||||
companion object {
|
||||
private val TAG = Log.tag(CallLogPagedDataSource::class)
|
||||
}
|
||||
|
||||
private val hasFilter = filter == CallLogFilter.MISSED
|
||||
private val hasCallLinkRow = filter == CallLogFilter.ALL && query.isNullOrEmpty()
|
||||
|
||||
|
@ -15,12 +21,21 @@ class CallLogPagedDataSource(
|
|||
private var callLinksCount = 0
|
||||
|
||||
override fun size(): Int {
|
||||
val stopwatch = Stopwatch("size")
|
||||
|
||||
callEventsCount = repository.getCallsCount(query, filter)
|
||||
stopwatch.split("calls")
|
||||
|
||||
callLinksCount = repository.getCallLinksCount(query, filter)
|
||||
stopwatch.split("call-links")
|
||||
stopwatch.stop(TAG)
|
||||
|
||||
return callEventsCount + callLinksCount + hasFilter.toInt() + hasCallLinkRow.toInt()
|
||||
}
|
||||
|
||||
override fun load(start: Int, length: Int, totalSize: Int, cancellationSignal: PagedDataSource.CancellationSignal): MutableList<CallLogRow> {
|
||||
val stopwatch = Stopwatch("load($start, $length)")
|
||||
|
||||
val callLogRows = mutableListOf<CallLogRow>()
|
||||
if (length <= 0) {
|
||||
return callLogRows
|
||||
|
@ -35,6 +50,7 @@ class CallLogPagedDataSource(
|
|||
callLogRows.add(CallLogRow.CreateCallLink)
|
||||
remaining -= 1
|
||||
}
|
||||
stopwatch.split("init")
|
||||
|
||||
if (start < callEventStart && remaining > 0) {
|
||||
val callLinks = repository.getCallLinks(
|
||||
|
@ -48,6 +64,7 @@ class CallLogPagedDataSource(
|
|||
|
||||
remaining -= callLinks.size
|
||||
}
|
||||
stopwatch.split("call-links")
|
||||
|
||||
if (start < clearFilterStart && remaining > 0) {
|
||||
val callEvents = repository.getCalls(
|
||||
|
@ -61,12 +78,16 @@ class CallLogPagedDataSource(
|
|||
|
||||
remaining -= callEvents.size
|
||||
}
|
||||
stopwatch.split("calls")
|
||||
|
||||
if (hasFilter && start <= clearFilterStart && remaining > 0) {
|
||||
callLogRows.add(CallLogRow.ClearFilter)
|
||||
}
|
||||
|
||||
repository.onCallTabPageLoaded(callLogRows)
|
||||
stopwatch.split("callback")
|
||||
stopwatch.stop(TAG)
|
||||
|
||||
return callLogRows
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue