changeset 38258:ae6e02fcee24

perftemplating: allow to specify the template to test This is useful to test the evolution of rendering time for a given template.
author Boris Feld <boris.feld@octobus.net>
date Thu, 31 May 2018 19:34:08 +0200
parents a577a199983c
children af402c6b90db
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Thu May 31 19:23:04 2018 +0200
+++ b/contrib/perf.py	Thu May 31 19:34:08 2018 +0200
@@ -909,7 +909,8 @@
 @command('perftemplating',
          [('r', 'rev', [], 'revisions to run the template on'),
          ] + formatteropts)
-def perftemplating(ui, repo, **opts):
+def perftemplating(ui, repo, testedtemplate=None, **opts):
+    """test the rendering time of a given template"""
     if makelogtemplater is None:
         ui.write_err('incompatible Mercurial version')
         return 1
@@ -922,9 +923,11 @@
         revs = ['all()']
     revs = list(scmutil.revrange(repo, revs))
 
-    template = ('{date|shortdate} [{rev}:{node|short}]'
-                ' {author|person}: {desc|firstline}\n')
-    displayer = makelogtemplater(nullui, repo, template)
+    defaulttemplate = ('{date|shortdate} [{rev}:{node|short}]'
+                       ' {author|person}: {desc|firstline}\n')
+    if testedtemplate is None:
+        testedtemplate = defaulttemplate
+    displayer = makelogtemplater(nullui, repo, testedtemplate)
     def format():
         for r in revs:
             ctx = repo[r]
--- a/tests/test-contrib-perf.t	Thu May 31 19:23:04 2018 +0200
+++ b/tests/test-contrib-perf.t	Thu May 31 19:34:08 2018 +0200
@@ -113,7 +113,7 @@
    perfstatus    (no help text available)
    perftags      (no help text available)
    perftemplating
-                 (no help text available)
+                 test the rendering time of a given template
    perfunidiff   benchmark a unified diff between revisions
    perfvolatilesets
                  benchmark the computation of various volatile set