contrib/perf.py
changeset 40941 db6cace18765
parent 40925 008f3491dc53
child 40945 ebc471ce9fad
--- a/contrib/perf.py	Thu Dec 13 14:44:54 2018 -0500
+++ b/contrib/perf.py	Thu Dec 13 17:10:03 2018 +0100
@@ -37,6 +37,7 @@
     copies,
     error,
     extensions,
+    hg,
     mdiff,
     merge,
     revlog,
@@ -67,6 +68,11 @@
     from mercurial import scmutil # since 1.9 (or 8b252e826c68)
 except ImportError:
     pass
+try:
+    from mercurial import setdiscovery # since 1.9 (or cb98fed52495)
+except ImportError:
+    pass
+
 
 def identity(a):
     return a
@@ -581,6 +587,21 @@
     timer(d)
     fm.end()
 
+@command(b'perfdiscovery', formatteropts, b'PATH')
+def perfdiscovery(ui, repo, path, **opts):
+    """benchmark discovery between local repo and the peer at given path
+    """
+    repos = [repo, None]
+    timer, fm = gettimer(ui, opts)
+    path = ui.expandpath(path)
+
+    def s():
+        repos[1] = hg.peer(ui, opts, path)
+    def d():
+        setdiscovery.findcommonheads(ui, *repos)
+    timer(d, setup=s)
+    fm.end()
+
 @command(b'perfbookmarks', formatteropts +
         [
             (b'', b'clear-revlogs', False, b'refresh changelog and manifest'),