[PATCH] perf: get the timer function through
Augie Fackler
raf at durin42.com
Tue Nov 4 13:25:06 UTC 2014
On Tue, Nov 4, 2014 at 8:23 AM, Pierre-Yves David
<pierre-yves.david at ens-lyon.org> wrote:
>
>
> On 11/04/2014 01:20 PM, Augie Fackler wrote:
>>
>> On Tue, Nov 04, 2014 at 01:08:45PM +0000, Pierre-Yves David wrote:
>>>
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david at fb.com>
>>> # Date 1415097606 0
>>> # Tue Nov 04 10:40:06 2014 +0000
>>> # Node ID cec5c3a6139b79da12956a612df4f793c521408f
>>> # Parent 30e0dcd7c5ffd99fb9c2474e9d73ca01a7d292fa
>>> perf: get the timer function through
>>
>>
>> This summary line confuses me. Would "perf: use a formatter for
>> output" be better?
>
>
> Looks like my last summary update got lost in limbo: here is the new
> version:
>
> perf: use a formatter for output
LG. Can you do me a favor and either push a cleaned-up version where I
can snag it or do a resend?
>
> We use a `formatter` object in the perf extensions. This allow the use of
> formatted output like json. To avoid adding logic to create a formatter and
> pass
> it around to the timer function in every command, we add a `gettimer`
> function
> in charge of returning a `timer` function as simple as before but embedding
> an
> appropriate formatter.
>
> This new `gettimer` function also return the formatter as it needs to be
> explicitly closed at the end of the command.
>
> example output:
>
>
> $ hg --config ui.formatjson=True perfvolatilesets visible obsolete
> [
> {
> "comb": 0.02,
> "count": 126,
> "sys": 0.0,
> "title": "obsolete",
> "user": 0.02,
> "wall": 0.0199398994446
> },
> {
> "comb": 0.02,
> "count": 117,
> "sys": 0.0,
> "title": "visible",
> "user": 0.02,
> "wall": 0.0250301361084
> }
> ]
>
>
>>
>>>
>>> We want to use a `formatter` object in the perf extensions. This will
>>> allow the
>>> use of formatted output like json. To avoid adding logic to create a
>>> formatter
>>> and passe it around to the timer function to every function, we add a
>>> function
>>> in charge of returning a `timer` function as simple as before but
>>> embedding an
>>> appropriate formatter.
>>
>>
>> +1
>>
>>>
>>> This new `gettimer` function also return the formatter as it needs to be
>>> explicitly closed at the end of the command.
>>>
>>> example output:
>>>
>>>
>>> $ hg --config ui.formatjson=True perfvolatilesets visible obsolete
>>> [
>>> {
>>> "comb": 0.02,
>>> "count": 126,
>>> "sys": 0.0,
>>> "title": "obsolete",
>>> "user": 0.02,
>>> "wall": 0.0199398994446
>>> },
>>> {
>>> "comb": 0.02,
>>> "count": 117,
>>> "sys": 0.0,
>>> "title": "visible",
>>> "user": 0.02,
>>> "wall": 0.0250301361084
>>> }
>>> ]
>>>
>>> diff --git a/contrib/perf.py b/contrib/perf.py
>>> --- a/contrib/perf.py
>>> +++ b/contrib/perf.py
>>> @@ -2,15 +2,32 @@
>>> '''helper extension to measure performance'''
>>>
>>> from mercurial import cmdutil, scmutil, util, commands, obsolete
>>> from mercurial import repoview, branchmap, merge, copies
>>> import time, os, sys
>>> +import functools
>>>
>>> cmdtable = {}
>>> command = cmdutil.command(cmdtable)
>>>
>>> -def timer(func, title=None):
>>> +def gettimer(ui, opts=None):
>>>
>>
>> Bonus points if you can come up with a better name than gettimer,
>> since it also gets a formatter.
>>
>>> + """return a timer function and formatter: (timer, formatter)
>>> +
>>> + This functions exist to gather the creation of formatter in a single
>>> + place instead of duplicating it in all performance command.
>>> +
>>> + (the formatter creation code is not yet here)
>>
>>
>> But I see a ui.formatter() below? Am I missing something?
>
>
> oops forgot to drop this line when folding.
>
>
> --
> Pierre-Yves David
More information about the Mercurial-devel
mailing list