Mercurial > hg-stable
changeset 49447:3c5d0f879404
perf-unbundle: add a perf command to time the unbundle operation
Check documentation for details.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 12 Jul 2022 01:13:56 +0200 |
parents | b380583ad2f5 |
children | 5fe7e9eda0f3 |
files | contrib/perf.py tests/test-contrib-perf.t |
diffstat | 2 files changed, 56 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Mon Jul 11 23:30:24 2022 +0200 +++ b/contrib/perf.py Tue Jul 12 01:13:56 2022 +0200 @@ -2590,6 +2590,51 @@ @command( + b'perf::unbundle', + formatteropts, + b'BUNDLE_FILE', +) +def perf_unbundle(ui, repo, fname, **opts): + """benchmark application of a bundle in a repository. + + This does not include the final transaction processing""" + from mercurial import exchange + from mercurial import bundle2 + + with repo.lock(): + bundle = [None, None] + try: + with open(fname, mode="rb") as f: + + def setup(): + gen, tr = bundle + if tr is not None: + tr.abort() + bundle[:] = [None, None] + f.seek(0) + bundle[0] = exchange.readbundle(ui, f, fname) + bundle[1] = repo.transaction(b'perf::unbundle') + + def apply(): + gen, tr = bundle + bundle2.applybundle( + repo, + gen, + tr, + source=b'perf::unbundle', + url=fname, + ) + + timer, fm = gettimer(ui, opts) + timer(apply, setup=setup) + fm.end() + finally: + gen, tr = bundle + if tr is not None: + tr.abort() + + +@command( b'perf::unidiff|perfunidiff', revlogopts + formatteropts
--- a/tests/test-contrib-perf.t Mon Jul 11 23:30:24 2022 +0200 +++ b/tests/test-contrib-perf.t Tue Jul 12 01:13:56 2022 +0200 @@ -188,6 +188,8 @@ perf::tags (no help text available) perf::templating test the rendering time of a given template + perf::unbundle + benchmark application of a bundle in a repository. perf::unidiff benchmark a unified diff between revisions perf::volatilesets @@ -387,6 +389,15 @@ searching for changes searching for changes $ hg perf::bundle 'last(all(), 5)' + $ hg bundle --exact --rev 'last(all(), 5)' last-5.hg + 4 changesets found + $ hg perf::unbundle last-5.hg + adding changesets + adding manifests + adding file changes + transaction abort! + rollback completed + test profile-benchmark option ------------------------------