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 | f41ae76152bacd1f088c323cffb7fa334f69fe6d (patch) | |
tree | 4fd6a244c78e2fd6a6274cd60c1e535a1e4ef9bd | |
parent | 35ea82718c70d272c58c21c4672b4e7f56bd571f (diff) |
profile select
-rw-r--r-- | mail/src/leap/mail/imap/account.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/mail/src/leap/mail/imap/account.py b/mail/src/leap/mail/imap/account.py index fd35698..1b5d4a0 100644 --- a/mail/src/leap/mail/imap/account.py +++ b/mail/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): """ |