Patchwork [4,of,5] perf: add a new `perfmergecopies` command

login
register
mail settings
Submitter Pierre-Yves David
Date May 23, 2019, 4:47 p.m.
Message ID <2a0e626bc8f1b7ac1cf3.1558630078@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40214/
State Accepted
Headers show

Comments

Pierre-Yves David - May 23, 2019, 4:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1558615682 -7200
#      Thu May 23 14:48:02 2019 +0200
# Node ID 2a0e626bc8f1b7ac1cf38789fcc32876f8684f91
# Parent  1587f4e0cca53e0f6074599c079b664461877dfb
# EXP-Topic perf-mergecopies
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2a0e626bc8f1
perf: add a new `perfmergecopies` command

This command benchmark calls to `mercuria.copies.mergecopies`

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -963,6 +963,24 @@  def perfmergecalculate(ui, repo, **opts)
     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"""
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
@@ -134,6 +134,8 @@  perfstatus
                  usable
    perfmergecalculate
                  (no help text available)
+   perfmergecopies
+                 measure runtime of 'copies.mergecopies'
    perfmoonwalk  benchmark walking the changelog backwards
    perfnodelookup
                  (no help text available)