Patchwork [09,of,13] perf: use `setup` function in `perfdirfoldmap`

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 8, 2019, 11:47 a.m.
Message ID <c33255b2f828e29c1fb1.1570535276@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/42101/
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 1570515135 14400
#      Tue Oct 08 02:12:15 2019 -0400
# Node ID c33255b2f828e29c1fb1914f7d5cdd74008a26c5
# Parent  8a6ad5abbf29c925d1b2610714f9e68df1bbc8e1
# EXP-Topic perf-doc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c33255b2f828
perf: use `setup` function in `perfdirfoldmap`

The command seems to pre-date the introduction of the `setup` support in timer.
We move the line that is obviously about benchmark setup in such `setup`
function.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1170,14 +1170,16 @@  def perfdirfoldmap(ui, repo, **opts):
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     dirstate = repo.dirstate
-    b'a' in dirstate
+    dirstate._map.dirfoldmap.get(b'a')
+
+    def setup():
+        del dirstate._map.dirfoldmap
+        del dirstate._map._dirs
 
     def d():
         dirstate._map.dirfoldmap.get(b'a')
-        del dirstate._map.dirfoldmap
-        del dirstate._map._dirs
-
-    timer(d)
+
+    timer(d, setup=setup)
     fm.end()