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

@@ -5,7 +5,6 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.concurrent.GuardedBy;
@@ -20,8 +19,6 @@ import static java.util.logging.Level.FINE;
@NotNullByDefault
public class PoliteExecutor implements Executor {
private static final Level LOG_LEVEL = FINE;
private final Object lock = new Object();
@GuardedBy("lock")
private final Queue<Runnable> queue = new LinkedList<>();
@@ -51,9 +48,9 @@ public class PoliteExecutor implements Executor {
public void execute(Runnable r) {
long submitted = System.currentTimeMillis();
Runnable wrapped = () -> {
if (log.isLoggable(LOG_LEVEL)) {
if (log.isLoggable(FINE)) {
long queued = System.currentTimeMillis() - submitted;
log.log(LOG_LEVEL, "Queue time " + queued + " ms");
log.fine("Queue time " + queued + " ms");
}
try {
r.run();

View File

@@ -6,7 +6,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.logging.Level.FINE;
@@ -14,8 +13,6 @@ import static java.util.logging.Level.FINE;
@NotNullByDefault
public class TimeLoggingExecutor extends ThreadPoolExecutor {
private static final Level LOG_LEVEL = FINE;
private final Logger log;
public TimeLoggingExecutor(String tag, int corePoolSize, int maxPoolSize,
@@ -29,15 +26,15 @@ public class TimeLoggingExecutor extends ThreadPoolExecutor {
@Override
public void execute(Runnable r) {
if (log.isLoggable(LOG_LEVEL)) {
if (log.isLoggable(FINE)) {
long submitted = System.currentTimeMillis();
super.execute(() -> {
long started = System.currentTimeMillis();
long queued = started - submitted;
log.log(LOG_LEVEL, "Queue time " + queued + " ms");
log.fine("Queue time " + queued + " ms");
r.run();
long executing = System.currentTimeMillis() - started;
log.log(LOG_LEVEL, "Execution time " + executing + " ms");
log.fine("Execution time " + executing + " ms");
});
} else {
super.execute(r);

View File

@@ -30,6 +30,7 @@ import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.inject.Inject;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static org.briarproject.bramble.util.ByteUtils.INT_32_BYTES;
@@ -135,8 +136,8 @@ class CryptoComponentImpl implements CryptoComponent {
for (byte b : secret) allZero |= b;
if (allZero == 0) throw new GeneralSecurityException();
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Deriving shared secret took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Deriving shared secret took " + duration + " ms");
return secret;
}

View File

@@ -9,6 +9,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
class ScryptKdf implements PasswordBasedKdf {
@@ -55,8 +56,8 @@ class ScryptKdf implements PasswordBasedKdf {
SecretKey k = new SecretKey(SCrypt.generate(passwordBytes, salt, cost,
BLOCK_SIZE, PARALLELIZATION, SecretKey.LENGTH));
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO))
LOG.info("Deriving key from password took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Deriving key from password took " + duration + " ms");
return k;
}
}

View File

@@ -16,7 +16,7 @@ import java.util.logging.Logger;
import javax.annotation.concurrent.Immutable;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.FINE;
/**
* A key parser that uses the encoding defined in "SEC 1: Elliptic Curve
@@ -81,8 +81,8 @@ class Sec1KeyParser implements KeyParser {
ECPublicKeyParameters k = new ECPublicKeyParameters(pub, params);
PublicKey p = new Sec1PublicKey(k);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Parsing public key took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Parsing public key took " + duration + " ms");
return p;
}
@@ -100,8 +100,8 @@ class Sec1KeyParser implements KeyParser {
ECPrivateKeyParameters k = new ECPrivateKeyParameters(d, params);
PrivateKey p = new Sec1PrivateKey(k, keyBits);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Parsing private key took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Parsing private key took " + duration + " ms");
return p;
}
}

View File

@@ -30,6 +30,7 @@ import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import javax.inject.Inject;
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.lifecycle.LifecycleManager.LifecycleState.MIGRATING_DATABASE;
@@ -108,8 +109,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
LocalAuthor localAuthor = authorFactory
.createLocalAuthor(nickname, publicKey, privateKey);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Creating local author took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Creating local author took " + duration + " ms");
return localAuthor;
}
@@ -117,8 +118,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
long now = System.currentTimeMillis();
identityManager.registerLocalAuthor(author);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Registering local author took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Registering local author took " + duration + " ms");
}
@Override
@@ -133,10 +134,10 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
boolean reopened = db.open(this);
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
if (LOG.isLoggable(FINE)) {
if (reopened)
LOG.info("Reopening database took " + duration + " ms");
else LOG.info("Creating database took " + duration + " ms");
LOG.fine("Reopening database took " + duration + " ms");
else LOG.fine("Creating database took " + duration + " ms");
}
if (nickname != null) {
@@ -153,8 +154,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
start = System.currentTimeMillis();
c.createLocalState(txn);
duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
LOG.info("Starting client "
if (LOG.isLoggable(FINE)) {
LOG.fine("Starting client "
+ c.getClass().getSimpleName()
+ " took " + duration + " ms");
}
@@ -167,8 +168,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
start = System.currentTimeMillis();
s.startService();
duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
LOG.info("Starting service " + s.getClass().getSimpleName()
if (LOG.isLoggable(FINE)) {
LOG.fine("Starting service " + s.getClass().getSimpleName()
+ " took " + duration + " ms");
}
}
@@ -216,14 +217,14 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
long start = System.currentTimeMillis();
s.stopService();
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
LOG.info("Stopping service " + s.getClass().getSimpleName()
if (LOG.isLoggable(FINE)) {
LOG.fine("Stopping service " + s.getClass().getSimpleName()
+ " took " + duration + " ms");
}
}
for (ExecutorService e : executors) {
if (LOG.isLoggable(INFO)) {
LOG.info("Stopping executor "
if (LOG.isLoggable(FINE)) {
LOG.fine("Stopping executor "
+ e.getClass().getSimpleName());
}
e.shutdownNow();
@@ -231,8 +232,8 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
long start = System.currentTimeMillis();
db.close();
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO))
LOG.info("Closing database took " + duration + " ms");
if (LOG.isLoggable(FINE))
LOG.fine("Closing database took " + duration + " ms");
shutdownLatch.countDown();
} catch (DbException | ServiceException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -49,6 +49,7 @@ import java.util.logging.Logger;
import javax.annotation.concurrent.ThreadSafe;
import javax.inject.Inject;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -208,8 +209,8 @@ class PluginManagerImpl implements PluginManager, Service {
long start = System.currentTimeMillis();
plugin.start();
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
LOG.info("Starting plugin " + plugin.getId() + " took " +
if (LOG.isLoggable(FINE)) {
LOG.fine("Starting plugin " + plugin.getId() + " took " +
duration + " ms");
}
} catch (PluginException e) {
@@ -246,8 +247,8 @@ class PluginManagerImpl implements PluginManager, Service {
long start = System.currentTimeMillis();
plugin.stop();
long duration = System.currentTimeMillis() - start;
if (LOG.isLoggable(INFO)) {
LOG.info("Stopping plugin " + plugin.getId()
if (LOG.isLoggable(FINE)) {
LOG.fine("Stopping plugin " + plugin.getId()
+ " took " + duration + " ms");
}
} catch (InterruptedException e) {

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);