changeset 42384:f5f0a9490c05

perf: add a new `perfmergecopies` command This command benchmark calls to `mercurial.copies.mergecopies`
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 May 2019 14:48:02 +0200
parents 3a3592b40a95
children 21c436a3a4e8
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Thu May 23 14:02:01 2019 +0200
+++ b/contrib/perf.py	Thu May 23 14:48:02 2019 +0200
@@ -1004,6 +1004,24 @@
     timer(d)
     fm.end()
 
+@command(b'perfmergecopies',
+         [
+             (b'r', b'rev', b'.', b'rev to merge against'),
+             (b'', b'from', b'', b'rev to merge from'),
+             (b'', b'base', b'', b'the revision to use as base'),
+         ] + formatteropts)
+def perfmergecopies(ui, repo, **opts):
+    """measure runtime of `copies.mergecopies`"""
+    opts = _byteskwargs(opts)
+    timer, fm = gettimer(ui, opts)
+    wctx, rctx, ancestor = _getmergerevs(repo, opts)
+    def d():
+        # acceptremote is True because we don't want prompts in the middle of
+        # our benchmark
+        copies.mergecopies(repo, wctx, rctx, ancestor)
+    timer(d)
+    fm.end()
+
 @command(b'perfpathcopies', [], b"REV REV")
 def perfpathcopies(ui, repo, rev1, rev2, **opts):
     """benchmark the copy tracing logic"""
--- a/tests/test-contrib-perf.t	Thu May 23 14:02:01 2019 +0200
+++ b/tests/test-contrib-perf.t	Thu May 23 14:48:02 2019 +0200
@@ -141,6 +141,8 @@
                  usable
    perfmergecalculate
                  (no help text available)
+   perfmergecopies
+                 measure runtime of 'copies.mergecopies'
    perfmoonwalk  benchmark walking the changelog backwards
    perfnodelookup
                  (no help text available)