Patchwork [12,of,13] perf: introduce a perfdirstateiter command

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 8, 2019, 11:47 a.m.
Message ID <397c7843d0261382d642.1570535279@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/42106/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 8, 2019, 11:47 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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