Add better Loader performance logs.

This commit is contained in:
Greyson Parrelli 2019-12-02 23:32:54 -05:00
parent b0a6bb79f6
commit c1e6b6b086
3 changed files with 6 additions and 6 deletions

View File

@ -364,8 +364,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
protected void onCreate(Bundle state, boolean ready) { protected void onCreate(Bundle state, boolean ready) {
Log.i(TAG, "onCreate()");
RecipientId recipientId = getIntent().getParcelableExtra(RECIPIENT_EXTRA); RecipientId recipientId = getIntent().getParcelableExtra(RECIPIENT_EXTRA);
if (recipientId == null) { if (recipientId == null) {

View File

@ -146,7 +146,6 @@ public class ConversationFragment extends Fragment
private int previousOffset; private int previousOffset;
private int activeOffset; private int activeOffset;
private boolean firstLoad; private boolean firstLoad;
private long loaderStartTime;
private ActionMode actionMode; private ActionMode actionMode;
private Locale locale; private Locale locale;
private RecyclerView list; private RecyclerView list;
@ -654,7 +653,6 @@ public class ConversationFragment extends Fragment
@Override @Override
public @NonNull Loader<Cursor> onCreateLoader(int id, Bundle args) { public @NonNull Loader<Cursor> onCreateLoader(int id, Bundle args) {
Log.i(TAG, "onCreateLoader"); Log.i(TAG, "onCreateLoader");
loaderStartTime = System.currentTimeMillis();
int limit = args.getInt(KEY_LIMIT, PARTIAL_CONVERSATION_LIMIT); int limit = args.getInt(KEY_LIMIT, PARTIAL_CONVERSATION_LIMIT);
int offset = 0; int offset = 0;
@ -668,9 +666,7 @@ public class ConversationFragment extends Fragment
@Override @Override
public void onLoadFinished(@NonNull Loader<Cursor> cursorLoader, Cursor cursor) { public void onLoadFinished(@NonNull Loader<Cursor> cursorLoader, Cursor cursor) {
long loadTime = System.currentTimeMillis() - loaderStartTime;
int count = cursor.getCount(); int count = cursor.getCount();
Log.i(TAG, "onLoadFinished - took " + loadTime + " ms to load a cursor of size " + count);
ConversationLoader loader = (ConversationLoader)cursorLoader; ConversationLoader loader = (ConversationLoader)cursorLoader;
ConversationAdapter adapter = getListAdapter(); ConversationAdapter adapter = getListAdapter();

View File

@ -5,6 +5,8 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import androidx.loader.content.AsyncTaskLoader; import androidx.loader.content.AsyncTaskLoader;
import org.thoughtcrime.securesms.logging.Log;
/** /**
* A Loader similar to CursorLoader that doesn't require queries to go through the ContentResolver * A Loader similar to CursorLoader that doesn't require queries to go through the ContentResolver
* to get the benefits of reloading when content has changed. * to get the benefits of reloading when content has changed.
@ -71,11 +73,15 @@ public abstract class AbstractCursorLoader extends AsyncTaskLoader<Cursor> {
@Override @Override
public Cursor loadInBackground() { public Cursor loadInBackground() {
long startTime = System.currentTimeMillis();
Cursor newCursor = getCursor(); Cursor newCursor = getCursor();
if (newCursor != null) { if (newCursor != null) {
newCursor.getCount(); newCursor.getCount();
newCursor.registerContentObserver(observer); newCursor.registerContentObserver(observer);
} }
Log.d(TAG, "[" + getClass().getSimpleName() + "] Cursor load time: " + (System.currentTimeMillis() - startTime) + " ms");
return newCursor; return newCursor;
} }