[PATCH 12 of 13] perf: introduce a perfdirstateiter command

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Oct 8 07:47:59 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# 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()
 
 
+ at 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


More information about the Mercurial-devel mailing list