mercurial/profiling.py
changeset 30820 6a70cf94d1b5
parent 30664 69acfd2ca11e
child 30930 517bc1cd7033
equal deleted inserted replaced
30819:897726622877 30820:6a70cf94d1b5
    10 import contextlib
    10 import contextlib
    11 import time
    11 import time
    12 
    12 
    13 from .i18n import _
    13 from .i18n import _
    14 from . import (
    14 from . import (
       
    15     encoding,
    15     error,
    16     error,
    16     pycompat,
       
    17     util,
    17     util,
    18 )
    18 )
    19 
    19 
    20 @contextlib.contextmanager
    20 @contextlib.contextmanager
    21 def lsprofile(ui, fp):
    21 def lsprofile(ui, fp):
   118     """Start profiling.
   118     """Start profiling.
   119 
   119 
   120     Profiling is active when the context manager is active. When the context
   120     Profiling is active when the context manager is active. When the context
   121     manager exits, profiling results will be written to the configured output.
   121     manager exits, profiling results will be written to the configured output.
   122     """
   122     """
   123     profiler = pycompat.osgetenv('HGPROF')
   123     profiler = encoding.environ.get('HGPROF')
   124     if profiler is None:
   124     if profiler is None:
   125         profiler = ui.config('profiling', 'type', default='stat')
   125         profiler = ui.config('profiling', 'type', default='stat')
   126     if profiler not in ('ls', 'stat', 'flame'):
   126     if profiler not in ('ls', 'stat', 'flame'):
   127         ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler)
   127         ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler)
   128         profiler = 'stat'
   128         profiler = 'stat'