summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-17 10:45:39 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:39:51 -0400
commited270dcbdca5f3887953121aa0750f99b618dd3a (patch)
treedf78038f628d5dbe3a95887fbd7e5f12cf4cc592 /src/leap
parentf67aabeb382592f3d7d597acb0389b39a353d8b8 (diff)
profile select
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/mail/imap/account.py20
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):
"""