Patchwork [03,of,13] perf: use `setup` function in `perfdirstate`

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 8, 2019, 11:47 a.m.
Message ID <574a82b6c9e77c1ffd3e.1570535270@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/42097/
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 1570514230 14400
#      Tue Oct 08 01:57:10 2019 -0400
# Node ID 574a82b6c9e77c1ffd3e69d0649b720945b182c6
# Parent  ec08340eaebb19b13d9544616ac232cba7cd4e12
# EXP-Topic perf-doc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 574a82b6c9e7
perf: use `setup` function in `perfdirstate`

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
@@ -1112,11 +1112,13 @@  def perfdirstate(ui, repo, **opts):
     timer, fm = gettimer(ui, opts)
     b"a" in repo.dirstate
 
+    def setup():
+        repo.dirstate.invalidate()
+
     def d():
-        repo.dirstate.invalidate()
         b"a" in repo.dirstate
 
-    timer(d)
+    timer(d, setup=setup)
     fm.end()