From patchwork Tue Oct 8 11:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [12,of,13] perf: introduce a perfdirstateiter command From: Pierre-Yves David X-Patchwork-Id: 42106 Message-Id: <397c7843d0261382d642.1570535279@nodosa.octobus.net> To: mercurial-devel@mercurial-scm.org Date: Tue, 08 Oct 2019 07:47:59 -0400 # HG changeset patch # User Pierre-Yves David # Date 1570522984 14400 # Tue Oct 08 04:23:04 2019 -0400 # Node ID 397c7843d0261382d642b2e02b2685ab9367d6bb # Parent 3c1b646e3acdf5386b01a010e66bd102dbbb90e4 # EXP-Topic perf-doc # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 397c7843d026 perf: introduce a perfdirstateiter command This command benchmark an iteration over all the file in the dirstate. This will be useful to compare the Python and the Rust implementation of the dirstate. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -1183,6 +1183,23 @@ def perfdirfoldmap(ui, repo, **opts): fm.end() +@command(b'perfdirstateiter', formatteropts) +def perfdirstateiter(ui, repo, **opts): + """benchmap the full iteration over all dirstate entry + """ + opts = _byteskwargs(opts) + timer, fm = gettimer(ui, opts) + dirstate = repo.dirstate + b'a' in dirstate + + def d(): + for f in dirstate: + pass + + timer(d) + fm.end() + + @command(b'perfdirstatewrite', formatteropts) def perfdirstatewrite(ui, repo, **opts): """benchmap the time it take to write a dirstate on disk 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 @@ -112,6 +112,8 @@ perfstatus benchmap a 'dirstate.hasdir' call from an empty 'dirs' cache perfdirstatefoldmap benchmap a 'dirstate._map.filefoldmap.get()' request + perfdirstateiter + benchmap the full iteration over all dirstate entry perfdirstatewrite benchmap the time it take to write a dirstate on disk perfdiscovery @@ -207,6 +209,7 @@ perfstatus $ hg perfdirstate $ hg perfdirstatedirs $ hg perfdirstatefoldmap + $ hg perfdirstateiter $ hg perfdirstatewrite #if repofncache $ hg perffncacheencode