##// END OF EJS Templates
util: make timedcm context manager also emit trace events...
Augie Fackler -
r39293:497effb0 default
parent child Browse files
Show More
@@ -36,6 +36,7 b' import traceback'
36 import warnings
36 import warnings
37 import zlib
37 import zlib
38
38
39 from hgdemandimport import tracing
39 from .thirdparty import (
40 from .thirdparty import (
40 attr,
41 attr,
41 )
42 )
@@ -2896,7 +2897,7 b' class timedcmstats(object):'
2896 __str__ = encoding.strmethod(__bytes__)
2897 __str__ = encoding.strmethod(__bytes__)
2897
2898
2898 @contextlib.contextmanager
2899 @contextlib.contextmanager
2899 def timedcm():
2900 def timedcm(whencefmt='unknown timedcm', *whenceargs):
2900 """A context manager that produces timing information for a given context.
2901 """A context manager that produces timing information for a given context.
2901
2902
2902 On entering a timedcmstats instance is produced.
2903 On entering a timedcmstats instance is produced.
@@ -2908,7 +2909,8 b' def timedcm():'
2908 timedcm._nested += 1
2909 timedcm._nested += 1
2909 timing_stats = timedcmstats(level=timedcm._nested)
2910 timing_stats = timedcmstats(level=timedcm._nested)
2910 try:
2911 try:
2911 yield timing_stats
2912 with tracing.log(whencefmt, *whenceargs):
2913 yield timing_stats
2912 finally:
2914 finally:
2913 timing_stats.elapsed = timer() - timing_stats.start
2915 timing_stats.elapsed = timer() - timing_stats.start
2914 timedcm._nested -= 1
2916 timedcm._nested -= 1
General Comments 0
You need to be logged in to leave comments. Login now