summaryrefslogtreecommitdiff
path: root/mail/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-14 12:42:58 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:39:50 -0400
commit35ea82718c70d272c58c21c4672b4e7f56bd571f (patch)
tree14fa533377bb70bdaa6d22bc291501822bc0e3a3 /mail/src
parent254cb48927671f05c3ca9b95a298b8b2096dd828 (diff)
add cProfiler instrumentation
Diffstat (limited to 'mail/src')
-rw-r--r--mail/src/leap/mail/imap/service/imap.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py
index b79d42dd..1175cdc3 100644
--- a/mail/src/leap/mail/imap/service/imap.py
+++ b/mail/src/leap/mail/imap/service/imap.py
@@ -25,6 +25,7 @@ from twisted.internet import defer, threads
from twisted.internet.protocol import ServerFactory
from twisted.internet.error import CannotListenError
from twisted.mail import imap4
+from twisted.python import log
logger = logging.getLogger(__name__)
@@ -71,6 +72,15 @@ DO_MANHOLE = os.environ.get("LEAP_MAIL_MANHOLE", None)
if DO_MANHOLE:
from leap.mail.imap.service import manhole
+DO_PROFILE = os.environ.get("LEAP_PROFILE", None)
+if DO_PROFILE:
+ import cProfile
+ log.msg("Starting PROFILING...")
+
+ PROFILE_DAT = "/tmp/leap_mail_profile.pstats"
+ pr = cProfile.Profile()
+ pr.enable()
+
class IMAPAuthRealm(object):
"""
@@ -140,6 +150,11 @@ class LeapIMAPFactory(ServerFactory):
disk in another thread.
:rtype: Deferred
"""
+ if DO_PROFILE:
+ log.msg("Stopping PROFILING")
+ pr.disable()
+ pr.dump_stats(PROFILE_DAT)
+
ServerFactory.doStop(self)
if cv is not None: