profiling: do not profile debugshell command

Summary:
The debugshell command can be long running and contains uninteresting stuff.
Do not profile it.

Practically this hides showing the background statprof thread when using `%trace`.

Reviewed By: DurhamG

Differential Revision: D23278597

fbshipit-source-id: bad97de22e1be2be8b866bee705ea3a6755aa54b
This commit is contained in:
Jun Wu 2020-08-27 18:11:28 -07:00 committed by Facebook GitHub Bot
parent d92c80ebcc
commit 54cd73b41b
3 changed files with 15 additions and 5 deletions

View File

@ -1058,6 +1058,10 @@ def _dispatch(req):
cmd, func, args, options, cmdoptions, foundaliases = _parse(lui, args)
lui.cmdname = ui.cmdname = cmd
# Do not profile the 'debugshell' command.
if cmd == "debugshell":
profiler.stop()
if cmd == "help" and len(foundaliases) > 0:
cmd = foundaliases[0]
options["help"] = True

View File

@ -183,6 +183,7 @@ class profile(object):
self._profiler = None
self._entered = False
self._started = False
self._stopped = False
self._section = "profiling"
def __enter__(self):
@ -232,6 +233,15 @@ class profile(object):
self._profiler.__enter__()
def __exit__(self, exception_type, exception_value, traceback):
self._stop(exception_type, exception_value, traceback)
def stop(self):
self._stop(None, None, None)
def _stop(self, exception_type, exception_value, traceback):
if self._stopped:
return
self._stopped = True
propagate = None
if self._profiler is not None:
propagate = self._profiler.__exit__(

View File

@ -84,11 +84,7 @@ profiler extension could be loaded before other extensions
#endif
Test minelapsed config option
$ hg --profile --config profiling.minelapsed=1000 debugshell -c 'ui.write("1\n")'
1
$ hg --profile --config profiling.minelapsed=1 debugshell -c 'import time; time.sleep(1.1)' 2>&1 | grep Sample
Sample count: * (glob)
(This cannot be tested because profiling is disabled for 'debugshell')
Test other config sections