Patchwork [07,of,13] perf: use `setup` function in `perfdirstatefoldmap`

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 8, 2019, 11:47 a.m.
Message ID <701f359a9899d1a8b2ca.1570535274@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/42104/
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 1570515375 14400
#      Tue Oct 08 02:16:15 2019 -0400
# Node ID 701f359a9899d1a8b2cafea2aadc1f667dacd385
# Parent  877921fc4a78077e3f45d08253464930fbfa5ae0
# EXP-Topic perf-doc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 701f359a9899
perf: use `setup` function in `perfdirstatefoldmap`

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
@@ -1149,13 +1149,15 @@  def perfdirstatefoldmap(ui, repo, **opts
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     dirstate = repo.dirstate
-    b'a' in dirstate
+    dirstate._map.filefoldmap.get(b'a')
+
+    def setup():
+        del dirstate._map.filefoldmap
 
     def d():
         dirstate._map.filefoldmap.get(b'a')
-        del dirstate._map.filefoldmap
-
-    timer(d)
+
+    timer(d, setup=setup)
     fm.end()