changeset 39114:222aba766015

perf: time loading branchmap caches Differential Revision: https://phab.mercurial-scm.org/D4280
author Martijn Pieters <mj@octobus.net>
date Mon, 13 Aug 2018 20:31:01 +0100
parents e8532d00b729
children 2a4bfbb52111
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Thu Aug 16 00:13:41 2018 +0000
+++ b/contrib/perf.py	Mon Aug 13 20:31:01 2018 +0100
@@ -1751,6 +1751,31 @@
         branchcachewrite.restore()
     fm.end()
 
+@command('perfbranchmapload', [
+     ('f', 'filter', '', 'Specify repoview filter'),
+     ('', 'list', False, 'List brachmap filter caches'),
+    ] + formatteropts)
+def perfbranchmapread(ui, repo, filter='', list=False, **opts):
+    """benchmark reading the branchmap"""
+    if list:
+        for name, kind, st in repo.cachevfs.readdir(stat=True):
+            if name.startswith('branch2'):
+                filtername = name.partition('-')[2] or 'unfiltered'
+                ui.status('%s - %s\n'
+                          % (filtername, util.bytecount(st.st_size)))
+        return
+    if filter:
+        repo = repoview.repoview(repo, filter)
+    else:
+        repo = repo.unfiltered()
+    # try once without timer, the filter may not be cached
+    if branchmap.read(repo) is None:
+        raise error.Abort('No brachmap cached for %s repo'
+                          % (filter or 'unfiltered'))
+    timer, fm = gettimer(ui, opts)
+    timer(lambda: branchmap.read(repo) and None)
+    fm.end()
+
 @command('perfloadmarkers')
 def perfloadmarkers(ui, repo):
     """benchmark the time to parse the on-disk markers for a repo
--- a/tests/test-contrib-perf.t	Thu Aug 16 00:13:41 2018 +0000
+++ b/tests/test-contrib-perf.t	Mon Aug 13 20:31:01 2018 +0100
@@ -55,6 +55,8 @@
                  benchmark parsing bookmarks from disk to memory
    perfbranchmap
                  benchmark the update of a branchmap
+   perfbranchmapload
+                 benchmark reading the branchmap
    perfbundleread
                  Benchmark reading of bundle files.
    perfcca       (no help text available)