Move timing measurements down to FINE log level.

This commit is contained in:
akwizgran
2018-06-15 11:36:20 +01:00
parent a47a1cf442
commit ccee1febbc
20 changed files with 116 additions and 115 deletions

View File

@@ -25,6 +25,7 @@ import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
@@ -101,7 +102,7 @@ public class BriarApplicationImpl extends Application
}
}
rootLogger.addHandler(logHandler);
rootLogger.setLevel(INFO);
rootLogger.setLevel(IS_DEBUG_BUILD || IS_BETA_BUILD ? FINE : INFO);
LOG.info("Created");

View File

@@ -32,7 +32,7 @@ import java.util.logging.Logger;
import javax.annotation.Nullable;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.util.HtmlUtils.ARTICLE;
@@ -113,8 +113,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
Collection<BlogPostHeader> headers =
blogManager.getPostHeaders(groupId);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading headers took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading headers took " + duration + " ms");
Collection<BlogPostItem> items = new ArrayList<>(headers.size());
now = System.currentTimeMillis();
for (BlogPostHeader h : headers) {
@@ -123,8 +123,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
items.add(item);
}
duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading bodies took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading bodies took " + duration + " ms");
return items;
}
@@ -143,8 +143,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
long now = System.currentTimeMillis();
BlogPostItem item = getItem(header);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading body took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading body took " + duration + " ms");
handler.onResult(item);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
@@ -170,8 +170,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
BlogPostHeader header1 = getPostHeader(g, m);
BlogPostItem item = getItem(header1);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading post took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading post took " + duration + " ms");
handler.onResult(item);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))

View File

@@ -35,7 +35,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
@MethodsNotNullByDefault
@@ -161,8 +161,8 @@ class BlogControllerImpl extends BaseControllerImpl
boolean removable = blogManager.canBeRemoved(b);
BlogItem blog = new BlogItem(b, ours, removable);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading blog took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading blog took " + duration + " ms");
handler.onResult(blog);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
@@ -181,8 +181,8 @@ class BlogControllerImpl extends BaseControllerImpl
Blog b = blogManager.getBlog(groupId);
blogManager.removeBlog(b);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Removing blog took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Removing blog took " + duration + " ms");
handler.onResult(null);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))

View File

@@ -26,7 +26,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_ID;
@@ -110,8 +110,8 @@ class FeedControllerImpl extends BaseControllerImpl
}
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading all posts took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading all posts took " + duration + " ms");
handler.onResult(posts);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -129,8 +129,8 @@ class FeedControllerImpl extends BaseControllerImpl
Author a = identityManager.getLocalAuthor();
Blog b = blogManager.getPersonalBlog(a);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading blog took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading blog took " + duration + " ms");
handler.onResult(b);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -59,7 +59,7 @@ import javax.inject.Inject;
import static android.support.v4.app.ActivityOptionsCompat.makeSceneTransitionAnimation;
import static android.support.v4.view.ViewCompat.getTransitionName;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.android.contact.ConversationActivity.CONTACT_ID;
@@ -209,8 +209,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
}
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Full load took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Full load took " + duration + " ms");
displayContacts(revision, contacts);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -104,6 +104,7 @@ import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt.PromptSt
import static android.support.v4.view.ViewCompat.setTransitionName;
import static android.support.v7.util.SortedList.INVALID_POSITION;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_INTRODUCTION;
@@ -297,8 +298,8 @@ public class ConversationActivity extends BriarActivity
contactAuthorId = contact.getAuthor().getId();
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading contact took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading contact took " + duration + " ms");
loadMessages();
displayContactDetails();
} catch (NoSuchContactException e) {
@@ -358,8 +359,8 @@ public class ConversationActivity extends BriarActivity
invitations.addAll(blogInvitations);
invitations.addAll(groupInvitations);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading messages took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading messages took " + duration + " ms");
displayMessages(revision, headers, introductions, invitations);
} catch (NoSuchContactException e) {
finishOnUiThread();
@@ -441,8 +442,8 @@ public class ConversationActivity extends BriarActivity
long now = System.currentTimeMillis();
String body = messagingManager.getMessageBody(m);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading body took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading body took " + duration + " ms");
displayMessageBody(m, body);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -692,8 +693,8 @@ public class ConversationActivity extends BriarActivity
long now = System.currentTimeMillis();
messagingManager.addLocalMessage(m);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Storing message took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Storing message took " + duration + " ms");
Message message = m.getMessage();
PrivateMessageHeader h = new PrivateMessageHeader(
message.getId(), message.getGroupId(),
@@ -819,8 +820,8 @@ public class ConversationActivity extends BriarActivity
long now = System.currentTimeMillis();
messagingManager.setReadFlag(g, m, true);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Marking read took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Marking read took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}

View File

@@ -28,7 +28,7 @@ import javax.inject.Inject;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.widget.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
@@ -125,8 +125,8 @@ public class CreateForumActivity extends BriarActivity {
long now = System.currentTimeMillis();
Forum f = forumManager.addForum(name);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Storing forum took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Storing forum took " + duration + " ms");
displayForum(f);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -44,7 +44,7 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_ID;
@@ -169,8 +169,8 @@ public class ForumListFragment extends BaseEventFragment implements
}
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Full load took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Full load took " + duration + " ms");
displayForums(revision, forums);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -197,8 +197,8 @@ public class ForumListFragment extends BaseEventFragment implements
long now = System.currentTimeMillis();
int available = forumSharingManager.getInvitations().size();
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading available took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading available took " + duration + " ms");
displayAvailableForums(available);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -17,7 +17,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
@NotNullByDefault
public class PasswordControllerImpl extends ConfigControllerImpl
@@ -89,8 +89,8 @@ public class PasswordControllerImpl extends ConfigControllerImpl
long now = System.currentTimeMillis();
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Key derivation took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Key derivation took " + duration + " ms");
return StringUtils.toHexString(encrypted);
}
}

View File

@@ -36,7 +36,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
@@ -162,8 +162,8 @@ class GroupListControllerImpl extends DbControllerImpl
}
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading groups took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading groups took " + duration + " ms");
handler.onResult(items);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -179,8 +179,8 @@ class GroupListControllerImpl extends DbControllerImpl
long now = System.currentTimeMillis();
groupManager.removePrivateGroup(g);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Removing group took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Removing group took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
handler.onException(e);

View File

@@ -59,6 +59,7 @@ import static android.provider.Settings.EXTRA_CHANNEL_ID;
import static android.provider.Settings.System.DEFAULT_NOTIFICATION_URI;
import static android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_LTR;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PREF_BT_ENABLE;
@@ -248,8 +249,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
Settings torSettings =
settingsManager.getSettings(TOR_NAMESPACE);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading settings took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading settings took " + duration + " ms");
boolean btSetting =
btSettings.getBoolean(PREF_BT_ENABLE, false);
int torSetting = torSettings.getInt(PREF_TOR_NETWORK,
@@ -438,8 +439,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
long now = System.currentTimeMillis();
settingsManager.mergeSettings(s, TOR_NAMESPACE);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Merging settings took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Merging settings took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
@@ -454,8 +455,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
long now = System.currentTimeMillis();
settingsManager.mergeSettings(s, BT_NAMESPACE);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Merging settings took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Merging settings took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
@@ -468,8 +469,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
long now = System.currentTimeMillis();
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Merging settings took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Merging settings took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}

View File

@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;
@MethodsNotNullByDefault
@@ -94,13 +94,12 @@ public abstract class InvitationControllerImpl<I extends InvitationItem>
public void loadInvitations(boolean clear,
ResultExceptionHandler<Collection<I>, DbException> handler) {
runOnDbThread(() -> {
Collection<I> invitations = new ArrayList<>();
try {
long now = System.currentTimeMillis();
invitations.addAll(getInvitations());
Collection<I> invitations = new ArrayList<>(getInvitations());
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading invitations took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading invitations took " + duration + " ms");
handler.onResult(invitations);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -134,8 +135,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
long now = System.currentTimeMillis();
G groupItem = loadNamedGroup();
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading group took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading group took " + duration + " ms");
handler.onResult(groupItem);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
@@ -158,8 +159,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
long now = System.currentTimeMillis();
Collection<H> headers = loadHeaders();
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading headers took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading headers took " + duration + " ms");
// Load bodies into cache
now = System.currentTimeMillis();
@@ -170,8 +171,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
}
}
duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading bodies took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Loading bodies took " + duration + " ms");
// Build and hand over items
handler.onResult(buildItems(headers));
@@ -202,8 +203,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
markRead(i.getId());
}
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Marking read took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Marking read took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
@@ -221,8 +222,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
H header = addLocalMessage(msg);
bodyCache.put(msg.getMessage().getId(), body);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Storing message took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Storing message took " + duration + " ms");
resultHandler.onResult(buildItem(header, body));
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -242,8 +243,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
G groupItem = loadNamedGroup();
deleteNamedGroup(groupItem);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Removing group took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Removing group took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
handler.onException(e);