# HG changeset patch # User Gregory Szorc # Date 2016-11-06 06:41:52 # Node ID c8fa7ad1ff908fe6a1c829f03ddce676f9a9bd05 # Parent 5581b294f3c6434d83d2ecda225e0c7bd8e88faf perf: add perfbdiff bdiff shows up a lot in profiling. I think it would be useful to have a perf command that runs bdiff over and over so we can find hot spots. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -25,6 +25,7 @@ import random import sys import time from mercurial import ( + bdiff, changegroup, cmdutil, commands, @@ -746,6 +747,30 @@ 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""" + if opts.get('changelog') or opts.get('manifest'): + file_, rev = None, file_ + elif rev is None: + raise error.CommandError('perfbdiff', 'invalid arguments') + + 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) + + def d(): + bdiff.bdiff(text1, text2) + + timer, fm = gettimer(ui, opts) + timer(d) + fm.end() + @command('perfdiffwd', formatteropts) def perfdiffwd(ui, repo, **opts): """Profile diff of working directory changes""" 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 @@ -50,6 +50,7 @@ perfstatus perfancestorset (no help text available) perfannotate (no help text available) + perfbdiff benchmark a bdiff between a revision and its delta parent perfbranchmap benchmark the update of a branchmap perfcca (no help text available) @@ -112,6 +113,7 @@ perfstatus $ hg perfancestors $ hg perfancestorset 2 $ hg perfannotate a + $ hg perfbdiff -c 1 $ hg perfbranchmap $ hg perfcca $ hg perfchangegroupchangelog