Patchwork [1,of,5] perf: add a --from flag to perfmergecalculate

login
register
mail settings
Submitter Pierre-Yves David
Date May 23, 2019, 4:47 p.m.
Message ID <041e1cfff879810c62af.1558630075@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40213/
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 1558603188 -7200
#      Thu May 23 11:19:48 2019 +0200
# Node ID 041e1cfff879810c62afef3101db4e8b016a62a4
# Parent  b162229ebe0de1cac21b8287ecee5f2ef0a9d530
# EXP-Topic perf-mergecopies
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 041e1cfff879
perf: add a --from flag to perfmergecalculate

Before this change, `perfmergecalculate` was always benchmarking the merge of
the working copy with another revision. We can now benchmark the
`mergecalculate` call for any arbitrary pair of revision.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -923,16 +923,24 @@  def perfdirstatewrite(ui, repo, **opts):
     fm.end()
 
 @command(b'perfmergecalculate',
-         [(b'r', b'rev', b'.', b'rev to merge against')] + formatteropts)
+         [
+             (b'r', b'rev', b'.', b'rev to merge against'),
+             (b'', b'from', b'', b'rev to merge from'),
+         ] + formatteropts)
 def perfmergecalculate(ui, repo, rev, **opts):
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
-    wctx = repo[None]
+
+    if opts['from']:
+        fromrev = scmutil.revsingle(repo, opts['from'])
+        wctx = repo[fromrev]
+    else:
+        wctx = repo[None]
+        # we don't want working dir files to be stat'd in the benchmark, so
+        # prime that cache
+        wctx.dirty()
     rctx = scmutil.revsingle(repo, rev, rev)
     ancestor = wctx.ancestor(rctx)
-    # we don't want working dir files to be stat'd in the benchmark, so prime
-    # that cache
-    wctx.dirty()
     def d():
         # acceptremote is True because we don't want prompts in the middle of
         # our benchmark