summaryrefslogtreecommitdiff
path: root/src/leap
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
commitf67aabeb382592f3d7d597acb0389b39a353d8b8 (patch)
tree389c95814f42ae419cb60c9aed0e32bac762edf5 /src/leap
parent45733a231128cc06e123f352b4eb9886d6820878 (diff)
add cProfiler instrumentation
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/mail/imap/service/imap.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py
index b79d42d..1175cdc 100644
--- a/src/leap/mail/imap/service/imap.py
+++ b/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: