Patchwork [1,of,3] perf: prepare to handle multiple pairs in perfbdiff

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 6, 2016, 7:03 p.m.
Message ID <b8907ec6c08b8215ea89.1478458995@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17375/
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 1478454674 28800
#      Sun Nov 06 09:51:14 2016 -0800
# Node ID b8907ec6c08b8215ea8937ecd5f801006d433604
# Parent  38f7d48d4a8399dc14e95250697fc98bfeafb1fc
perf: prepare to handle multiple pairs in perfbdiff

Before, we only supported benchmarking a single pair of texts
with bdiff. We want to enable feeding larger corpora into this
benchmark. So rewrite the code to support that.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -755,17 +755,18 @@  def perfbdiff(ui, repo, file_, rev=None,
     elif rev is None:
         raise error.CommandError('perfbdiff', 'invalid arguments')
 
+    textpairs = []
+
     r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts)
 
     node = r.lookup(rev)
     rev = r.rev(node)
     dp = r.deltaparent(rev)
-
-    text1 = r.revision(dp)
-    text2 = r.revision(node)
+    textpairs.append((r.revision(dp), r.revision(node)))
 
     def d():
-        bdiff.bdiff(text1, text2)
+        for pair in textpairs:
+            bdiff.bdiff(*pair)
 
     timer, fm = gettimer(ui, opts)
     timer(d)