diff options
author | Kali Kaneko <kali@leap.se> | 2014-02-17 10:45:39 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-02-17 11:39:51 -0400 |
commit | ed270dcbdca5f3887953121aa0750f99b618dd3a (patch) | |
tree | df78038f628d5dbe3a95887fbd7e5f12cf4cc592 /src/leap/mail | |
parent | f67aabeb382592f3d7d597acb0389b39a353d8b8 (diff) |
profile select
Diffstat (limited to 'src/leap/mail')
-rw-r--r-- | src/leap/mail/imap/account.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/leap/mail/imap/account.py b/src/leap/mail/imap/account.py index fd35698..1b5d4a0 100644 --- a/src/leap/mail/imap/account.py +++ b/src/leap/mail/imap/account.py @@ -19,9 +19,11 @@ Soledad Backed Account. """ import copy import logging +import os import time from twisted.mail import imap4 +from twisted.python import log from zope.interface import implements from leap.common.check import leap_assert, leap_assert_type @@ -33,6 +35,15 @@ from leap.soledad.client import Soledad logger = logging.getLogger(__name__) +PROFILE_CMD = os.environ.get('LEAP_PROFILE_IMAPCMD', False) + +if PROFILE_CMD: + + def _debugProfiling(result, cmdname, start): + took = (time.time() - start) * 1000 + log.msg("CMD " + cmdname + " TOOK: " + str(took) + " msec") + return result + ####################################### # Soledad Account @@ -235,15 +246,20 @@ class SoledadBackedAccount(WithMsgFields, IndexedDB, MBoxParser): :rtype: SoledadMailbox """ - name = self._parse_mailbox_name(name) + if PROFILE_CMD: + start = time.time() + name = self._parse_mailbox_name(name) if name not in self.mailboxes: logger.warning("No such mailbox!") return None self.selected = name - return SoledadMailbox( + sm = SoledadMailbox( name, self._soledad, self._memstore, readwrite) + if PROFILE_CMD: + _debugProfiling(None, "SELECT", start) + return sm def delete(self, name, force=False): """ |