mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Don't calculate duration unless needed.
This commit is contained in:
@@ -113,9 +113,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
|
||||
long start = now();
|
||||
Collection<BlogPostHeader> headers =
|
||||
blogManager.getPostHeaders(groupId);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading headers took " + duration + " ms");
|
||||
LOG.fine("Loading headers took " + (now() - start) + " ms");
|
||||
Collection<BlogPostItem> items = new ArrayList<>(headers.size());
|
||||
start = now();
|
||||
for (BlogPostHeader h : headers) {
|
||||
@@ -123,9 +122,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
|
||||
BlogPostItem item = getItem(h);
|
||||
items.add(item);
|
||||
}
|
||||
duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading bodies took " + duration + " ms");
|
||||
LOG.fine("Loading bodies took " + (now() - start) + " ms");
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -143,9 +141,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
|
||||
try {
|
||||
long start = now();
|
||||
BlogPostItem item = getItem(header);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading body took " + duration + " ms");
|
||||
LOG.fine("Loading body took " + (now() - start) + " ms");
|
||||
handler.onResult(item);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
@@ -170,9 +167,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
|
||||
long start = now();
|
||||
BlogPostHeader header1 = getPostHeader(g, m);
|
||||
BlogPostItem item = getItem(header1);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading post took " + duration + " ms");
|
||||
LOG.fine("Loading post took " + (now() - start) + " ms");
|
||||
handler.onResult(item);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
|
||||
@@ -161,9 +161,8 @@ class BlogControllerImpl extends BaseControllerImpl
|
||||
boolean ours = a.getId().equals(b.getAuthor().getId());
|
||||
boolean removable = blogManager.canBeRemoved(b);
|
||||
BlogItem blog = new BlogItem(b, ours, removable);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading blog took " + duration + " ms");
|
||||
LOG.fine("Loading blog took " + (now() - start) + " ms");
|
||||
handler.onResult(blog);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
@@ -181,9 +180,8 @@ class BlogControllerImpl extends BaseControllerImpl
|
||||
long start = now();
|
||||
Blog b = blogManager.getBlog(groupId);
|
||||
blogManager.removeBlog(b);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Removing blog took " + duration + " ms");
|
||||
LOG.fine("Removing blog took " + (now() - start) + " ms");
|
||||
handler.onResult(null);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
|
||||
@@ -110,9 +110,10 @@ class FeedControllerImpl extends BaseControllerImpl
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Loading all posts took " + duration + " ms");
|
||||
}
|
||||
handler.onResult(posts);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -209,9 +209,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Full load took " + duration + " ms");
|
||||
LOG.fine("Full load took " + (now() - start) + " ms");
|
||||
displayContacts(revision, contacts);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -298,9 +298,8 @@ public class ConversationActivity extends BriarActivity
|
||||
contactName = contact.getAuthor().getName();
|
||||
contactAuthorId = contact.getAuthor().getId();
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading contact took " + duration + " ms");
|
||||
LOG.fine("Loading contact took " + (now() - start) + " ms");
|
||||
loadMessages();
|
||||
displayContactDetails();
|
||||
} catch (NoSuchContactException e) {
|
||||
@@ -359,9 +358,10 @@ public class ConversationActivity extends BriarActivity
|
||||
invitations.addAll(forumInvitations);
|
||||
invitations.addAll(blogInvitations);
|
||||
invitations.addAll(groupInvitations);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Loading messages took " + duration + " ms");
|
||||
}
|
||||
displayMessages(revision, headers, introductions, invitations);
|
||||
} catch (NoSuchContactException e) {
|
||||
finishOnUiThread();
|
||||
@@ -442,9 +442,8 @@ public class ConversationActivity extends BriarActivity
|
||||
try {
|
||||
long start = now();
|
||||
String body = messagingManager.getMessageBody(m);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading body took " + duration + " ms");
|
||||
LOG.fine("Loading body took " + (now() - start) + " ms");
|
||||
displayMessageBody(m, body);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
@@ -693,9 +692,8 @@ public class ConversationActivity extends BriarActivity
|
||||
try {
|
||||
long start = now();
|
||||
messagingManager.addLocalMessage(m);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Storing message took " + duration + " ms");
|
||||
LOG.fine("Storing message took " + (now() - start) + " ms");
|
||||
Message message = m.getMessage();
|
||||
PrivateMessageHeader h = new PrivateMessageHeader(
|
||||
message.getId(), message.getGroupId(),
|
||||
@@ -820,9 +818,8 @@ public class ConversationActivity extends BriarActivity
|
||||
try {
|
||||
long start = now();
|
||||
messagingManager.setReadFlag(g, m, true);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Marking read took " + duration + " ms");
|
||||
LOG.fine("Marking read took " + (now() - start) + " ms");
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
|
||||
@@ -125,9 +125,8 @@ public class CreateForumActivity extends BriarActivity {
|
||||
try {
|
||||
long start = now();
|
||||
Forum f = forumManager.addForum(name);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Storing forum took " + duration + " ms");
|
||||
LOG.fine("Storing forum took " + (now() - start) + " ms");
|
||||
displayForum(f);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -169,9 +169,8 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Full load took " + duration + " ms");
|
||||
LOG.fine("Full load took " + (now() - start) + " ms");
|
||||
displayForums(revision, forums);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
@@ -197,9 +196,10 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
try {
|
||||
long start = now();
|
||||
int available = forumSharingManager.getInvitations().size();
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Loading available took " + duration + " ms");
|
||||
}
|
||||
displayAvailableForums(available);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -89,9 +89,8 @@ public class PasswordControllerImpl extends ConfigControllerImpl
|
||||
String encryptDatabaseKey(SecretKey key, String password) {
|
||||
long start = now();
|
||||
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Key derivation took " + duration + " ms");
|
||||
LOG.fine("Key derivation took " + (now() - start) + " ms");
|
||||
return StringUtils.toHexString(encrypted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,9 +162,8 @@ class GroupListControllerImpl extends DbControllerImpl
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading groups took " + duration + " ms");
|
||||
LOG.fine("Loading groups took " + (now() - start) + " ms");
|
||||
handler.onResult(items);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
@@ -179,9 +178,8 @@ class GroupListControllerImpl extends DbControllerImpl
|
||||
try {
|
||||
long start = now();
|
||||
groupManager.removePrivateGroup(g);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Removing group took " + duration + " ms");
|
||||
LOG.fine("Removing group took " + (now() - start) + " ms");
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
handler.onException(e);
|
||||
|
||||
@@ -249,9 +249,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
Settings btSettings = settingsManager.getSettings(BT_NAMESPACE);
|
||||
Settings torSettings =
|
||||
settingsManager.getSettings(TOR_NAMESPACE);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Loading settings took " + duration + " ms");
|
||||
}
|
||||
boolean btSetting =
|
||||
btSettings.getBoolean(PREF_BT_ENABLE, false);
|
||||
int torSetting = torSettings.getInt(PREF_TOR_NETWORK,
|
||||
@@ -439,9 +440,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
s.putInt(PREF_TOR_NETWORK, torSetting);
|
||||
long start = now();
|
||||
settingsManager.mergeSettings(s, TOR_NAMESPACE);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Merging settings took " + duration + " ms");
|
||||
}
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
@@ -455,9 +457,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
s.putBoolean(PREF_BT_ENABLE, btSetting);
|
||||
long start = now();
|
||||
settingsManager.mergeSettings(s, BT_NAMESPACE);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Merging settings took " + duration + " ms");
|
||||
}
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
@@ -469,9 +472,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
try {
|
||||
long start = now();
|
||||
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Merging settings took " + duration + " ms");
|
||||
}
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
|
||||
@@ -98,9 +98,10 @@ public abstract class InvitationControllerImpl<I extends InvitationItem>
|
||||
try {
|
||||
long start = now();
|
||||
Collection<I> invitations = new ArrayList<>(getInvitations());
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
if (LOG.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
LOG.fine("Loading invitations took " + duration + " ms");
|
||||
}
|
||||
handler.onResult(invitations);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -135,9 +135,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
try {
|
||||
long start = now();
|
||||
G groupItem = loadNamedGroup();
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading group took " + duration + " ms");
|
||||
LOG.fine("Loading group took " + (now() - start) + " ms");
|
||||
handler.onResult(groupItem);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
@@ -159,9 +158,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
// Load headers
|
||||
long start = now();
|
||||
Collection<H> headers = loadHeaders();
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading headers took " + duration + " ms");
|
||||
LOG.fine("Loading headers took " + (now() - start) + " ms");
|
||||
|
||||
// Load bodies into cache
|
||||
start = now();
|
||||
@@ -171,9 +169,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
loadMessageBody(header));
|
||||
}
|
||||
}
|
||||
duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Loading bodies took " + duration + " ms");
|
||||
LOG.fine("Loading bodies took " + (now() - start) + " ms");
|
||||
|
||||
// Build and hand over items
|
||||
handler.onResult(buildItems(headers));
|
||||
@@ -203,9 +200,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
for (I i : items) {
|
||||
markRead(i.getId());
|
||||
}
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Marking read took " + duration + " ms");
|
||||
LOG.fine("Marking read took " + (now() - start) + " ms");
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
@@ -222,9 +218,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
long start = now();
|
||||
H header = addLocalMessage(msg);
|
||||
bodyCache.put(msg.getMessage().getId(), body);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Storing message took " + duration + " ms");
|
||||
LOG.fine("Storing message took " + (now() - start) + " ms");
|
||||
resultHandler.onResult(buildItem(header, body));
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
@@ -243,9 +238,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
|
||||
long start = now();
|
||||
G groupItem = loadNamedGroup();
|
||||
deleteNamedGroup(groupItem);
|
||||
long duration = now() - start;
|
||||
if (LOG.isLoggable(FINE))
|
||||
LOG.fine("Removing group took " + duration + " ms");
|
||||
LOG.fine("Removing group took " + (now() - start) + " ms");
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
handler.onException(e);
|
||||
|
||||
Reference in New Issue
Block a user