changeset 26186:eb2187ebdf8a

profiling: add config option for enabling profiling Previously you could only enable profiling via the --profile option. This is awkward when trying to debug a server side operation. Let's add a config option to enable profiling. In the future, this could be extended to allow profiling a certain percentage of operations (and potentially reporting that information to an external service).
author Durham Goode <durham@fb.com>
date Mon, 07 Sep 2015 11:35:40 -0700
parents e8f9dffca36f
children 9cf65f43b49b
files mercurial/dispatch.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Mon Sep 07 11:31:44 2015 -0700
+++ b/mercurial/dispatch.py	Mon Sep 07 11:35:40 2015 -0700
@@ -1003,13 +1003,17 @@
         statprof.display(fp)
 
 def _runcommand(ui, options, cmd, cmdfunc):
+    """Enables the profiler if applicable.
+
+    ``profiling.enabled`` - boolean config that enables or disables profiling
+    """
     def checkargs():
         try:
             return cmdfunc()
         except error.SignatureError:
             raise error.CommandError(cmd, _("invalid arguments"))
 
-    if options['profile']:
+    if options['profile'] or ui.configbool('profiling', 'enabled'):
         profiler = os.getenv('HGPROF')
         if profiler is None:
             profiler = ui.config('profiling', 'type', default='ls')