[PATCH 4 of 7 V2] profiling: add a context manager that no-ops if profiling isn't enabled
Yuya Nishihara
yuya at tcha.org
Tue Aug 16 00:19:39 EDT 2016
On Sun, 14 Aug 2016 18:37:41 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1471222272 25200
> # Sun Aug 14 17:51:12 2016 -0700
> # Node ID fd7b55561853e9d5532f3a9265433a7b614f2687
> # Parent 3338d4536f490fca055881b4e3884b28e4e25d22
> profiling: add a context manager that no-ops if profiling isn't enabled
> --- a/mercurial/help/config.txt
> +++ b/mercurial/help/config.txt
> @@ -1388,16 +1388,22 @@ Specifies profiling type, format, and fi
> supported: an instrumenting profiler (named ``ls``), and a sampling
> profiler (named ``stat``).
>
> In this section description, 'profiling data' stands for the raw data
> collected during profiling, while 'profiling report' stands for a
> statistical text report generated from the profiling data. The
> profiling is done using lsprof.
>
> +``enabled``
> + Enable the profiler.
> + (default: false)
> +
> + This is equivalent to passing ``--profile`` on the command line.
> +
> +def maybeprofile(ui):
> + """Profile if enabled, else do nothing.
> +
> + This context manager can be used to optionally profile if profiling
> + is enabled. Otherwise, it does nothing.
> +
> + The purpose of this context manager is to make calling code simpler:
> + just use a single code path for calling into code you may want to profile
> + and this function determines whether to start profiling.
> + """
> + # internal config profiling.enabled
Removed this line because profiling.enabled is now documented.
More information about the Mercurial-devel
mailing list