Patchwork [3,of,8,V2] perf: run 'setup' function during stub run

login
register
mail settings
Submitter Boris Feld
Date Nov. 26, 2018, 6:44 p.m.
Message ID <0adc2c0a0792d4a0015e.1543257874@localhost.localdomain>
Download mbox | patch
Permalink /patch/36794/
State Accepted
Headers show

Comments

Boris Feld - Nov. 26, 2018, 6:44 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542926924 -3600
#      Thu Nov 22 23:48:44 2018 +0100
# Node ID 0adc2c0a0792d4a0015ec0634487ed9e08fd0e7e
# Parent  0a3cc351d7189969b98c7f926b408837683f003b
# EXP-Topic perf-branchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0adc2c0a0792
perf: run 'setup' function during stub run

The benchmarked function might need the content of the setup to be run in order
to function properly.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -276,6 +276,8 @@  def gettimer(ui, opts=None):
     return functools.partial(_timer, fm, displayall=displayall), fm
 
 def stub_timer(fm, func, setup=None, title=None):
+    if setup is not None:
+        setup()
     func()
 
 @contextlib.contextmanager