Mercurial > hg
changeset 30307:c8fa7ad1ff90
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 05 Nov 2016 23:41:52 -0700 |
parents | 5581b294f3c6 |
children | d500ddae7494 |
files | contrib/perf.py tests/test-contrib-perf.t |
diffstat | 2 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Sun Nov 06 06:54:31 2016 +0530 +++ b/contrib/perf.py Sat Nov 05 23:41:52 2016 -0700 @@ -25,6 +25,7 @@ import sys import time from mercurial import ( + bdiff, changegroup, cmdutil, commands, @@ -746,6 +747,30 @@ 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"""
--- a/tests/test-contrib-perf.t Sun Nov 06 06:54:31 2016 +0530 +++ b/tests/test-contrib-perf.t Sat Nov 05 23:41:52 2016 -0700 @@ -50,6 +50,7 @@ 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 @@ $ hg perfancestors $ hg perfancestorset 2 $ hg perfannotate a + $ hg perfbdiff -c 1 $ hg perfbranchmap $ hg perfcca $ hg perfchangegroupchangelog