Mercurial > hg > mercurial-source
changeset 30797:bd6df07ccc24
perf: add perfchangegroupchangelog command
This command can be used for testing the performance of producing the
changelog portion of a changegroup.
We could use additional perf* commands for testing other parts of
changegroup. Those can be written another time, when they are needed.
(And those may want to refactor the changegroup generation API so code
can be reused.) Speaking of code reuse, yes, this command does reinvent
a small wheel. I didn't want to scope bloat to change the changegroup
API because that will invite bikeshedding.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 24 Sep 2016 12:22:30 -0700 |
parents | 973cf6c3de30 |
children | 6ca3c54f801b |
files | contrib/perf.py tests/test-contrib-perf.t |
diffstat | 2 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py +++ b/contrib/perf.py @@ -25,6 +25,7 @@ import sys import time from mercurial import ( + changegroup, cmdutil, commands, copies, @@ -279,6 +280,37 @@ timer(d) fm.end() +@command('perfchangegroupchangelog', formatteropts + + [('', 'version', '02', 'changegroup version'), + ('r', 'rev', '', 'revisions to add to changegroup')]) +def perfchangegroupchangelog(ui, repo, version='02', rev=None, **opts): + """Benchmark producing a changelog group for a changegroup. + + This measures the time spent processing the changelog during a + bundle operation. This occurs during `hg bundle` and on a server + processing a `getbundle` wire protocol request (handles clones + and pull requests). + + By default, all revisions are added to the changegroup. + """ + cl = repo.changelog + revs = [cl.lookup(r) for r in repo.revs(rev or 'all()')] + bundler = changegroup.getbundler(version, repo) + + def lookup(node): + # The real bundler reads the revision in order to access the + # manifest node and files list. Do that here. + cl.read(node) + return node + + def d(): + for chunk in bundler.group(revs, cl, lookup): + pass + + timer, fm = gettimer(ui, opts) + timer(d) + fm.end() + @command('perfdirs', formatteropts) def perfdirs(ui, repo, **opts): timer, fm = gettimer(ui, opts)
--- a/tests/test-contrib-perf.t +++ b/tests/test-contrib-perf.t @@ -53,6 +53,8 @@ perfbranchmap benchmark the update of a branchmap perfcca (no help text available) + perfchangegroupchangelog + Benchmark producing a changelog group for a changegroup. perfchangeset (no help text available) perfctxfiles (no help text available) @@ -112,6 +114,7 @@ $ hg perfannotate a $ hg perfbranchmap $ hg perfcca + $ hg perfchangegroupchangelog $ hg perfchangeset 2 $ hg perfctxfiles 2 $ hg perfdiffwd