# HG changeset patch # User Pierre-Yves David # Date 1657572659 -7200 # Node ID b081a5aab782b7be06eb79e740109f0ceca2af8c # Parent 2bbd7bc7d6c4d54476619a48073a8c10569d80bc perf-bundle: add a new command to benchmark bundle creation time diff -r 2bbd7bc7d6c4 -r b081a5aab782 contrib/perf.py --- a/contrib/perf.py Tue Jul 12 01:34:18 2022 +0200 +++ b/contrib/perf.py Mon Jul 11 22:50:59 2022 +0200 @@ -974,6 +974,56 @@ fm.end() +@command(b'perf::bundle', formatteropts, b'REVS') +def perfbundle(ui, repo, *revs, **opts): + """benchmark the creation of a bundle from a repository + + For now, this create a `none-v1` bundle. + """ + from mercurial import bundlecaches + from mercurial import discovery + from mercurial import bundle2 + + opts = _byteskwargs(opts) + timer, fm = gettimer(ui, opts) + + cl = repo.changelog + revs = scmutil.revrange(repo, revs) + if not revs: + raise error.Abort(b"not revision specified") + # make it a consistent set (ie: without topological gaps) + old_len = len(revs) + revs = list(repo.revs(b"%ld::%ld", revs, revs)) + if old_len != len(revs): + new_count = len(revs) - old_len + msg = b"add %d new revisions to make it a consistent set\n" + ui.write_err(msg % new_count) + + targets = [cl.node(r) for r in repo.revs(b"heads(::%ld)", revs)] + bases = [cl.node(r) for r in repo.revs(b"heads(::%ld - %ld)", revs, revs)] + outgoing = discovery.outgoing(repo, bases, targets) + + bundlespec = bundlecaches.parsebundlespec( + repo, b"none", strict=False + ) + + bversion = b'HG10' + bundlespec.wirecompression + + def do_bundle(): + bundle2.writenewbundle( + ui, + repo, + b'perf::bundle', + os.devnull, + bversion, + outgoing, + {}, + ) + + timer(do_bundle) + fm.end() + + @command(b'perf::bundleread|perfbundleread', formatteropts, b'BUNDLE') def perfbundleread(ui, repo, bundlepath, **opts): """Benchmark reading of bundle files. diff -r 2bbd7bc7d6c4 -r b081a5aab782 tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t Tue Jul 12 01:34:18 2022 +0200 +++ b/tests/test-contrib-perf.t Mon Jul 11 22:50:59 2022 +0200 @@ -96,6 +96,7 @@ perf::branchmapupdate benchmark branchmap update from for revs to revs + perf::bundle benchmark the creation of a bundle from a repository perf::bundleread Benchmark reading of bundle files. perf::cca (no help text available) @@ -385,6 +386,7 @@ searching for changes searching for changes searching for changes + $ hg perf::bundle 'last(all(), 5)' test profile-benchmark option ------------------------------