Add profiling options
authorChristophe de Vienne <christophe@unlish.com>
Sat, 03 Jan 2015 17:07:21 +0100
changeset 11648 9a112017974a
parent 11647 7f2cfe9f79cb
child 11649 8914052abdca
Add profiling options
ccplugin.py
--- a/ccplugin.py	Sat Jan 03 02:39:43 2015 +0100
+++ b/ccplugin.py	Sat Jan 03 17:07:21 2015 +0100
@@ -57,6 +57,20 @@
           'default': None, 'choices': ('debug', 'info', 'warning', 'error'),
           'help': 'debug if -D is set, error otherwise',
           }),
+        ('profile',
+         {'short': 'p', 'action': 'store_true',
+          'default': False,
+          'help': 'Enable profiling'}),
+        ('profile-output',
+         {'type': 'string',
+          'default': None,
+          'help': 'Profiling output file (default: "program.prof")'}),
+        ('profile-dump-every',
+         {'type': 'int',
+          'default': None,
+          'metavar': 'N',
+          'help': 'Dump profile stats to ouput every N requests '
+                  '(default: 100)'}),
     )
 
     _reloader_environ_key = 'CW_RELOADER_SHOULD_RUN'
@@ -285,7 +299,11 @@
         host = cwconfig['interface']
         port = cwconfig['port'] or 8080
 
-        app = wsgi_application_from_cwconfig(cwconfig)
+        app = wsgi_application_from_cwconfig(
+            cwconfig, profile=self['profile'],
+            profile_output=self['profile-output'],
+            profile_dump_every=self['profile-dump-every']
+        )
 
         repo = cwconfig.repository()
         try: