Patchwork [2,of,3] perf: support bdiffing multiple revisions in a single revlog

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 6, 2016, 7:03 p.m.
Message ID <91a510590fa6f4003f59.1478458996@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17376/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 6, 2016, 7:03 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478458885 28800
#      Sun Nov 06 11:01:25 2016 -0800
# Node ID 91a510590fa6f4003f596bf661cb17da8800ecde
# Parent  b8907ec6c08b8215ea8937ecd5f801006d433604
perf: support bdiffing multiple revisions in a single revlog

This is useful for testing bdiff performance on several revision
pairs at a time.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -747,9 +747,17 @@  def perffncacheencode(ui, repo, **opts):
     timer(d)
     fm.end()
 
-@command('perfbdiff', revlogopts + formatteropts, '-c|-m|FILE REV')
-def perfbdiff(ui, repo, file_, rev=None, **opts):
-    """benchmark a bdiff between a revision and its delta parent"""
+@command('perfbdiff', revlogopts + formatteropts + [
+    ('', 'count', 1, 'number of revisions to test (when using --startrev)')],
+    '-c|-m|FILE REV')
+def perfbdiff(ui, repo, file_, rev=None, count=None, **opts):
+    """benchmark a bdiff between revisions
+
+    By default, benchmark a bdiff between its delta parent and itself.
+
+    With ``--count``, benchmark bdiffs between delta parents and self for N
+    revisions starting at the specified revision.
+    """
     if opts.get('changelog') or opts.get('manifest'):
         file_, rev = None, file_
     elif rev is None:
@@ -759,10 +767,10 @@  def perfbdiff(ui, repo, file_, rev=None,
 
     r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts)
 
-    node = r.lookup(rev)
-    rev = r.rev(node)
-    dp = r.deltaparent(rev)
-    textpairs.append((r.revision(dp), r.revision(node)))
+    startrev = r.rev(r.lookup(rev))
+    for rev in range(startrev, min(startrev + count, len(r) - 1)):
+        dp = r.deltaparent(rev)
+        textpairs.append((r.revision(dp), r.revision(rev)))
 
     def d():
         for pair in textpairs: