[PATCH 2 of 2] perfbranchmap: allow to select the filter to benchmark

Boris Feld boris.feld at octobus.net
Wed Feb 21 09:38:12 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1519209792 -3600
#      Wed Feb 21 11:43:12 2018 +0100
# Node ID ddab5cae846a3e05ec4b951472e562fce06301ea
# Parent  f40e09835c645bbc0b535228ac743d84e952f866
# EXP-Topic filter-perfbranchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ddab5cae846a
perfbranchmap: allow to select the filter to benchmark

Running the branchmap computation on all filter levels can be expensive.
Narrowing the run to some specific filters can speed up benchmarking time when
working only on a subset of filter levels.

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1568,11 +1568,13 @@ def perfvolatilesets(ui, repo, *names, *
           ('', 'clear-revbranch', False,
            'purge the revbranch cache between computation'),
          ] + formatteropts)
-def perfbranchmap(ui, repo, full=False, clear_revbranch=False, **opts):
+def perfbranchmap(ui, repo, *filternames, **opts):
     """benchmark the update of a branchmap
 
     This benchmarks the full repo.branchmap() call with read and write disabled
     """
+    full = opts.get("full", False)
+    clear_revbranch = opts.get("clear_revbranch", False)
     timer, fm = gettimer(ui, opts)
     def getbranchmap(filtername):
         """generate a benchmark function for the filtername"""
@@ -1591,6 +1593,9 @@ def perfbranchmap(ui, repo, full=False, 
         return d
     # add filter in smaller subset to bigger subset
     possiblefilters = set(repoview.filtertable)
+    print("FILTERNAMES", filternames)
+    if filternames:
+        possiblefilters &= set(filternames)
     subsettable = getbranchmapsubsettable()
     allfilters = []
     while possiblefilters:
@@ -1607,8 +1612,9 @@ def perfbranchmap(ui, repo, full=False, 
     if not full:
         for name in allfilters:
             repo.filtered(name).branchmap()
-    # add unfiltered
-    allfilters.append(None)
+    if not filternames or 'unfiltered' in filternames:
+        # add unfiltered
+        allfilters.append(None)
 
     branchcacheread = safeattrsetter(branchmap, 'read')
     branchcachewrite = safeattrsetter(branchmap.branchcache, 'write')


More information about the Mercurial-devel mailing list