From patchwork Tue May 23 14:04:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3] perfchangelog: add 'perfchangelog' command From: Pierre-Yves David X-Patchwork-Id: 20862 Message-Id: <73e20c262b133cf3117a.1495548263@nodosa.octopoid.net> To: mercurial-devel@mercurial-scm.org Date: Tue, 23 May 2017 16:04:23 +0200 # HG changeset patch # User Pierre-Yves David # Date 1495499078 -7200 # Tue May 23 02:24:38 2017 +0200 # Node ID 73e20c262b133cf3117a7148e6293b5721e8930d # Parent c79b8f2a95a35ce1b41325d003337c65bc5bffca # EXP-Topic perf # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 73e20c262b13 perfchangelog: add 'perfchangelog' command That command monitor the time spend initializing a new changelog object. If I'm not mistaken this includes reading the file on disk and building the nodemap. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -488,6 +488,22 @@ def perfchangegroupchangelog(ui, repo, v timer(d) fm.end() +def _clearchangelog(repo): + if 'changelog' in vars(repo): + del repo.changelog + del repo._filecache['changelog'] + +@command('perfchangelog', [], "") +def perfchangelog(ui, repo, **opts): + """benchmark the changelog initialization""" + timer, fm = gettimer(ui, opts) + repo = repo.unfiltered() + def d(): + _clearchangelog(repo) + repo.changelog + timer(d) + fm.end() + @command('perfdirs', formatteropts) def perfdirs(ui, repo, **opts): timer, fm = gettimer(ui, opts) 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 @@ -56,6 +56,8 @@ perfstatus perfcca (no help text available) perfchangegroupchangelog Benchmark producing a changelog group for a changegroup. + perfchangelog + benchmark the changelog initialization perfchangeset (no help text available) perfctxfiles (no help text available)