Mercurial > hg-stable
changeset 38269:a577a199983c
perftemplating: stop going through the log command
Only benchmark the rendering phase by moving steps outside of the timed
function:
* revisions resolution,
* template parsing
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 31 May 2018 19:23:04 +0200 |
parents | b8f75bc9f623 |
children | ae6e02fcee24 |
files | contrib/perf.py |
diffstat | 1 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Thu May 31 18:48:08 2018 +0200 +++ b/contrib/perf.py Thu May 31 19:23:04 2018 +0200 @@ -81,6 +81,15 @@ except (AttributeError, ImportError): queue = util.queue +try: + from mercurial import logcmdutil + makelogtemplater = logcmdutil.maketemplater +except (AttributeError, ImportError): + try: + makelogtemplater = cmdutil.makelogtemplater + except (AttributeError, ImportError): + makelogtemplater = None + # for "historical portability": # define util.safehasattr forcibly, because util.safehasattr has been # available since 1.9.3 (or 94b200a11cf7) @@ -901,14 +910,26 @@ [('r', 'rev', [], 'revisions to run the template on'), ] + formatteropts) def perftemplating(ui, repo, **opts): + if makelogtemplater is None: + ui.write_err('incompatible Mercurial version') + return 1 + nullui = ui.copy() nullui.fout = open(os.devnull, 'wb') nullui.disablepager() revs = opts.get('rev') + if not revs: + revs = ['all()'] + revs = list(scmutil.revrange(repo, revs)) + + template = ('{date|shortdate} [{rev}:{node|short}]' + ' {author|person}: {desc|firstline}\n') + displayer = makelogtemplater(nullui, repo, template) def format(): - commands.log(nullui, repo, rev=revs, date='', user='', - template='{date|shortdate} [{rev}:{node|short}]' - ' {author|person}: {desc|firstline}\n') + for r in revs: + ctx = repo[r] + displayer.show(ctx) + displayer.flush(ctx) timer, fm = gettimer(ui, opts) timer(format)