[PATCH 6 of 6] perftemplating: allow to specify the template to test

Boris Feld boris.feld at octobus.net
Mon Jun 11 03:52:25 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1527788048 -7200
#      Thu May 31 19:34:08 2018 +0200
# Node ID e037022cc5f7e5af2e8cc7e7aa84a344f16c854b
# Parent  d3a7e385f495769fc0bdd37a0801dfb7ee7f153d
# EXP-Topic perftemplate
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e037022cc5f7
perftemplating: allow to specify the template to test

This is useful to test the evolution of rendering time for a given template.

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -910,7 +910,8 @@ def perfmoonwalk(ui, repo, **opts):
 @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
@@ -923,9 +924,11 @@ def perftemplating(ui, repo, **opts):
         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]
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -113,7 +113,7 @@ perfstatus
    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


More information about the Mercurial-devel mailing list