Don't calculate duration unless needed.

This commit is contained in:
akwizgran
2018-06-15 15:52:05 +01:00
parent 08931e64cb
commit 0d2a91289f
17 changed files with 65 additions and 87 deletions

View File

@@ -136,9 +136,8 @@ class CryptoComponentImpl implements CryptoComponent {
byte allZero = 0; byte allZero = 0;
for (byte b : secret) allZero |= b; for (byte b : secret) allZero |= b;
if (allZero == 0) throw new GeneralSecurityException(); if (allZero == 0) throw new GeneralSecurityException();
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Deriving shared secret took " + duration + " ms"); LOG.fine("Deriving shared secret took " + (now() - start) + " ms");
return secret; return secret;
} }

View File

@@ -56,9 +56,10 @@ class ScryptKdf implements PasswordBasedKdf {
byte[] passwordBytes = StringUtils.toUtf8(password); byte[] passwordBytes = StringUtils.toUtf8(password);
SecretKey k = new SecretKey(SCrypt.generate(passwordBytes, salt, cost, SecretKey k = new SecretKey(SCrypt.generate(passwordBytes, salt, cost,
BLOCK_SIZE, PARALLELIZATION, SecretKey.LENGTH)); BLOCK_SIZE, PARALLELIZATION, SecretKey.LENGTH));
long duration = now() - start; if (LOG.isLoggable(FINE)) {
if (LOG.isLoggable(FINE)) long duration = now() - start;
LOG.fine("Deriving key from password took " + duration + " ms"); LOG.fine("Deriving key from password took " + duration + " ms");
}
return k; return k;
} }
} }

View File

@@ -81,9 +81,8 @@ class Sec1KeyParser implements KeyParser {
// Construct a public key from the point (x, y) and the params // Construct a public key from the point (x, y) and the params
ECPublicKeyParameters k = new ECPublicKeyParameters(pub, params); ECPublicKeyParameters k = new ECPublicKeyParameters(pub, params);
PublicKey p = new Sec1PublicKey(k); PublicKey p = new Sec1PublicKey(k);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Parsing public key took " + duration + " ms"); LOG.fine("Parsing public key took " + (now() - start) + " ms");
return p; return p;
} }
@@ -100,9 +99,8 @@ class Sec1KeyParser implements KeyParser {
// Construct a private key from the private value and the params // Construct a private key from the private value and the params
ECPrivateKeyParameters k = new ECPrivateKeyParameters(d, params); ECPrivateKeyParameters k = new ECPrivateKeyParameters(d, params);
PrivateKey p = new Sec1PrivateKey(k, keyBits); PrivateKey p = new Sec1PrivateKey(k, keyBits);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Parsing private key took " + duration + " ms"); LOG.fine("Parsing private key took " + (now() - start) + " ms");
return p; return p;
} }
} }

View File

@@ -109,18 +109,18 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
byte[] privateKey = keyPair.getPrivate().getEncoded(); byte[] privateKey = keyPair.getPrivate().getEncoded();
LocalAuthor localAuthor = authorFactory LocalAuthor localAuthor = authorFactory
.createLocalAuthor(nickname, publicKey, privateKey); .createLocalAuthor(nickname, publicKey, privateKey);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Creating local author took " + duration + " ms"); LOG.fine("Creating local author took " + (now() - start) + " ms");
return localAuthor; return localAuthor;
} }
private void registerLocalAuthor(LocalAuthor author) throws DbException { private void registerLocalAuthor(LocalAuthor author) throws DbException {
long start = now(); long start = now();
identityManager.registerLocalAuthor(author); identityManager.registerLocalAuthor(author);
long duration = now() - start; if (LOG.isLoggable(FINE)) {
if (LOG.isLoggable(FINE)) LOG.fine("Registering local author took " + (now() - start)
LOG.fine("Registering local author took " + duration + " ms"); + " ms");
}
} }
@Override @Override
@@ -134,8 +134,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
long start = now(); long start = now();
boolean reopened = db.open(this); boolean reopened = db.open(this);
long duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
long duration = now() - start;
if (reopened) if (reopened)
LOG.fine("Reopening database took " + duration + " ms"); LOG.fine("Reopening database took " + duration + " ms");
else LOG.fine("Creating database took " + duration + " ms"); else LOG.fine("Creating database took " + duration + " ms");
@@ -154,11 +154,10 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
for (Client c : clients) { for (Client c : clients) {
start = now(); start = now();
c.createLocalState(txn); c.createLocalState(txn);
duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
LOG.fine("Starting client " LOG.fine("Starting client "
+ c.getClass().getSimpleName() + c.getClass().getSimpleName()
+ " took " + duration + " ms"); + " took " + (now() - start) + " ms");
} }
} }
db.commitTransaction(txn); db.commitTransaction(txn);
@@ -168,10 +167,9 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
for (Service s : services) { for (Service s : services) {
start = now(); start = now();
s.startService(); s.startService();
duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
LOG.fine("Starting service " + s.getClass().getSimpleName() LOG.fine("Starting service " + s.getClass().getSimpleName()
+ " took " + duration + " ms"); + " took " + (now() - start) + " ms");
} }
} }
@@ -217,10 +215,9 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
for (Service s : services) { for (Service s : services) {
long start = now(); long start = now();
s.stopService(); s.stopService();
long duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
LOG.fine("Stopping service " + s.getClass().getSimpleName() LOG.fine("Stopping service " + s.getClass().getSimpleName()
+ " took " + duration + " ms"); + " took " + (now() - start) + " ms");
} }
} }
for (ExecutorService e : executors) { for (ExecutorService e : executors) {
@@ -232,9 +229,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
} }
long start = now(); long start = now();
db.close(); db.close();
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Closing database took " + duration + " ms"); LOG.fine("Closing database took " + (now() - start) + " ms");
shutdownLatch.countDown(); shutdownLatch.countDown();
} catch (DbException | ServiceException e) { } catch (DbException | ServiceException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -209,10 +209,9 @@ class PluginManagerImpl implements PluginManager, Service {
try { try {
long start = now(); long start = now();
plugin.start(); plugin.start();
long duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
LOG.fine("Starting plugin " + plugin.getId() + " took " + LOG.fine("Starting plugin " + plugin.getId()
duration + " ms"); + " took " + (now() - start) + " ms");
} }
} catch (PluginException e) { } catch (PluginException e) {
if (LOG.isLoggable(WARNING)) { if (LOG.isLoggable(WARNING)) {
@@ -247,10 +246,9 @@ class PluginManagerImpl implements PluginManager, Service {
// Stop the plugin // Stop the plugin
long start = now(); long start = now();
plugin.stop(); plugin.stop();
long duration = now() - start;
if (LOG.isLoggable(FINE)) { if (LOG.isLoggable(FINE)) {
LOG.fine("Stopping plugin " + plugin.getId() LOG.fine("Stopping plugin " + plugin.getId()
+ " took " + duration + " ms"); + " took " + (now() - start) + " ms");
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOG.warning("Interrupted while waiting for plugin to stop"); LOG.warning("Interrupted while waiting for plugin to stop");

View File

@@ -113,9 +113,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
long start = now(); long start = now();
Collection<BlogPostHeader> headers = Collection<BlogPostHeader> headers =
blogManager.getPostHeaders(groupId); blogManager.getPostHeaders(groupId);
long duration = now() - start;
if (LOG.isLoggable(FINE)) 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()); Collection<BlogPostItem> items = new ArrayList<>(headers.size());
start = now(); start = now();
for (BlogPostHeader h : headers) { for (BlogPostHeader h : headers) {
@@ -123,9 +122,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
BlogPostItem item = getItem(h); BlogPostItem item = getItem(h);
items.add(item); items.add(item);
} }
duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading bodies took " + duration + " ms"); LOG.fine("Loading bodies took " + (now() - start) + " ms");
return items; return items;
} }
@@ -143,9 +141,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
try { try {
long start = now(); long start = now();
BlogPostItem item = getItem(header); BlogPostItem item = getItem(header);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading body took " + duration + " ms"); LOG.fine("Loading body took " + (now() - start) + " ms");
handler.onResult(item); handler.onResult(item);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
@@ -170,9 +167,8 @@ abstract class BaseControllerImpl extends DbControllerImpl
long start = now(); long start = now();
BlogPostHeader header1 = getPostHeader(g, m); BlogPostHeader header1 = getPostHeader(g, m);
BlogPostItem item = getItem(header1); BlogPostItem item = getItem(header1);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading post took " + duration + " ms"); LOG.fine("Loading post took " + (now() - start) + " ms");
handler.onResult(item); handler.onResult(item);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))

View File

@@ -161,9 +161,8 @@ class BlogControllerImpl extends BaseControllerImpl
boolean ours = a.getId().equals(b.getAuthor().getId()); boolean ours = a.getId().equals(b.getAuthor().getId());
boolean removable = blogManager.canBeRemoved(b); boolean removable = blogManager.canBeRemoved(b);
BlogItem blog = new BlogItem(b, ours, removable); BlogItem blog = new BlogItem(b, ours, removable);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading blog took " + duration + " ms"); LOG.fine("Loading blog took " + (now() - start) + " ms");
handler.onResult(blog); handler.onResult(blog);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
@@ -181,9 +180,8 @@ class BlogControllerImpl extends BaseControllerImpl
long start = now(); long start = now();
Blog b = blogManager.getBlog(groupId); Blog b = blogManager.getBlog(groupId);
blogManager.removeBlog(b); blogManager.removeBlog(b);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Removing blog took " + duration + " ms"); LOG.fine("Removing blog took " + (now() - start) + " ms");
handler.onResult(null); handler.onResult(null);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))

View File

@@ -110,9 +110,10 @@ class FeedControllerImpl extends BaseControllerImpl
LOG.log(WARNING, e.toString(), e); 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"); LOG.fine("Loading all posts took " + duration + " ms");
}
handler.onResult(posts); handler.onResult(posts);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -209,9 +209,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
// Continue // Continue
} }
} }
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Full load took " + duration + " ms"); LOG.fine("Full load took " + (now() - start) + " ms");
displayContacts(revision, contacts); displayContacts(revision, contacts);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -298,9 +298,8 @@ public class ConversationActivity extends BriarActivity
contactName = contact.getAuthor().getName(); contactName = contact.getAuthor().getName();
contactAuthorId = contact.getAuthor().getId(); contactAuthorId = contact.getAuthor().getId();
} }
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading contact took " + duration + " ms"); LOG.fine("Loading contact took " + (now() - start) + " ms");
loadMessages(); loadMessages();
displayContactDetails(); displayContactDetails();
} catch (NoSuchContactException e) { } catch (NoSuchContactException e) {
@@ -359,9 +358,10 @@ public class ConversationActivity extends BriarActivity
invitations.addAll(forumInvitations); invitations.addAll(forumInvitations);
invitations.addAll(blogInvitations); invitations.addAll(blogInvitations);
invitations.addAll(groupInvitations); 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"); LOG.fine("Loading messages took " + duration + " ms");
}
displayMessages(revision, headers, introductions, invitations); displayMessages(revision, headers, introductions, invitations);
} catch (NoSuchContactException e) { } catch (NoSuchContactException e) {
finishOnUiThread(); finishOnUiThread();
@@ -442,9 +442,8 @@ public class ConversationActivity extends BriarActivity
try { try {
long start = now(); long start = now();
String body = messagingManager.getMessageBody(m); String body = messagingManager.getMessageBody(m);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading body took " + duration + " ms"); LOG.fine("Loading body took " + (now() - start) + " ms");
displayMessageBody(m, body); displayMessageBody(m, body);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -693,9 +692,8 @@ public class ConversationActivity extends BriarActivity
try { try {
long start = now(); long start = now();
messagingManager.addLocalMessage(m); messagingManager.addLocalMessage(m);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Storing message took " + duration + " ms"); LOG.fine("Storing message took " + (now() - start) + " ms");
Message message = m.getMessage(); Message message = m.getMessage();
PrivateMessageHeader h = new PrivateMessageHeader( PrivateMessageHeader h = new PrivateMessageHeader(
message.getId(), message.getGroupId(), message.getId(), message.getGroupId(),
@@ -820,9 +818,8 @@ public class ConversationActivity extends BriarActivity
try { try {
long start = now(); long start = now();
messagingManager.setReadFlag(g, m, true); messagingManager.setReadFlag(g, m, true);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Marking read took " + duration + " ms"); LOG.fine("Marking read took " + (now() - start) + " ms");
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }

View File

@@ -125,9 +125,8 @@ public class CreateForumActivity extends BriarActivity {
try { try {
long start = now(); long start = now();
Forum f = forumManager.addForum(name); Forum f = forumManager.addForum(name);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Storing forum took " + duration + " ms"); LOG.fine("Storing forum took " + (now() - start) + " ms");
displayForum(f); displayForum(f);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -169,9 +169,8 @@ public class ForumListFragment extends BaseEventFragment implements
// Continue // Continue
} }
} }
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Full load took " + duration + " ms"); LOG.fine("Full load took " + (now() - start) + " ms");
displayForums(revision, forums); displayForums(revision, forums);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -197,9 +196,10 @@ public class ForumListFragment extends BaseEventFragment implements
try { try {
long start = now(); long start = now();
int available = forumSharingManager.getInvitations().size(); 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"); LOG.fine("Loading available took " + duration + " ms");
}
displayAvailableForums(available); displayAvailableForums(available);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -89,9 +89,8 @@ public class PasswordControllerImpl extends ConfigControllerImpl
String encryptDatabaseKey(SecretKey key, String password) { String encryptDatabaseKey(SecretKey key, String password) {
long start = now(); long start = now();
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password); byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Key derivation took " + duration + " ms"); LOG.fine("Key derivation took " + (now() - start) + " ms");
return StringUtils.toHexString(encrypted); return StringUtils.toHexString(encrypted);
} }
} }

View File

@@ -162,9 +162,8 @@ class GroupListControllerImpl extends DbControllerImpl
// Continue // Continue
} }
} }
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading groups took " + duration + " ms"); LOG.fine("Loading groups took " + (now() - start) + " ms");
handler.onResult(items); handler.onResult(items);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -179,9 +178,8 @@ class GroupListControllerImpl extends DbControllerImpl
try { try {
long start = now(); long start = now();
groupManager.removePrivateGroup(g); groupManager.removePrivateGroup(g);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Removing group took " + duration + " ms"); LOG.fine("Removing group took " + (now() - start) + " ms");
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
handler.onException(e); handler.onException(e);

View File

@@ -249,9 +249,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
Settings btSettings = settingsManager.getSettings(BT_NAMESPACE); Settings btSettings = settingsManager.getSettings(BT_NAMESPACE);
Settings torSettings = Settings torSettings =
settingsManager.getSettings(TOR_NAMESPACE); 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"); LOG.fine("Loading settings took " + duration + " ms");
}
boolean btSetting = boolean btSetting =
btSettings.getBoolean(PREF_BT_ENABLE, false); btSettings.getBoolean(PREF_BT_ENABLE, false);
int torSetting = torSettings.getInt(PREF_TOR_NETWORK, int torSetting = torSettings.getInt(PREF_TOR_NETWORK,
@@ -439,9 +440,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
s.putInt(PREF_TOR_NETWORK, torSetting); s.putInt(PREF_TOR_NETWORK, torSetting);
long start = now(); long start = now();
settingsManager.mergeSettings(s, TOR_NAMESPACE); 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"); LOG.fine("Merging settings took " + duration + " ms");
}
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), 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); s.putBoolean(PREF_BT_ENABLE, btSetting);
long start = now(); long start = now();
settingsManager.mergeSettings(s, BT_NAMESPACE); 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"); LOG.fine("Merging settings took " + duration + " ms");
}
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -469,9 +472,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
try { try {
long start = now(); long start = now();
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE); 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"); LOG.fine("Merging settings took " + duration + " ms");
}
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }

View File

@@ -98,9 +98,10 @@ public abstract class InvitationControllerImpl<I extends InvitationItem>
try { try {
long start = now(); long start = now();
Collection<I> invitations = new ArrayList<>(getInvitations()); 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"); LOG.fine("Loading invitations took " + duration + " ms");
}
handler.onResult(invitations); handler.onResult(invitations);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -135,9 +135,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
try { try {
long start = now(); long start = now();
G groupItem = loadNamedGroup(); G groupItem = loadNamedGroup();
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading group took " + duration + " ms"); LOG.fine("Loading group took " + (now() - start) + " ms");
handler.onResult(groupItem); handler.onResult(groupItem);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
@@ -159,9 +158,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
// Load headers // Load headers
long start = now(); long start = now();
Collection<H> headers = loadHeaders(); Collection<H> headers = loadHeaders();
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading headers took " + duration + " ms"); LOG.fine("Loading headers took " + (now() - start) + " ms");
// Load bodies into cache // Load bodies into cache
start = now(); start = now();
@@ -171,9 +169,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
loadMessageBody(header)); loadMessageBody(header));
} }
} }
duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Loading bodies took " + duration + " ms"); LOG.fine("Loading bodies took " + (now() - start) + " ms");
// Build and hand over items // Build and hand over items
handler.onResult(buildItems(headers)); handler.onResult(buildItems(headers));
@@ -203,9 +200,8 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
for (I i : items) { for (I i : items) {
markRead(i.getId()); markRead(i.getId());
} }
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Marking read took " + duration + " ms"); LOG.fine("Marking read took " + (now() - start) + " ms");
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), 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(); long start = now();
H header = addLocalMessage(msg); H header = addLocalMessage(msg);
bodyCache.put(msg.getMessage().getId(), body); bodyCache.put(msg.getMessage().getId(), body);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Storing message took " + duration + " ms"); LOG.fine("Storing message took " + (now() - start) + " ms");
resultHandler.onResult(buildItem(header, body)); resultHandler.onResult(buildItem(header, body));
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), 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(); long start = now();
G groupItem = loadNamedGroup(); G groupItem = loadNamedGroup();
deleteNamedGroup(groupItem); deleteNamedGroup(groupItem);
long duration = now() - start;
if (LOG.isLoggable(FINE)) if (LOG.isLoggable(FINE))
LOG.fine("Removing group took " + duration + " ms"); LOG.fine("Removing group took " + (now() - start) + " ms");
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
handler.onException(e); handler.onException(e);