Patchwork [5,of,6,"] perf: pass limits as a function argument

login
register
mail settings
Submitter Pierre-Yves David
Date March 25, 2019, 1:19 p.m.
Message ID <3ec42dcfe522d2d72c65.1553519964@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39383/
State Accepted
Headers show

Comments

Pierre-Yves David - March 25, 2019, 1:19 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1552763479 0
#      Sat Mar 16 19:11:19 2019 +0000
# Node ID 3ec42dcfe522d2d72c65874e97b0c7ef67f46685
# Parent  89dba0ac07a2c581f527c807c61c36883013d323
# EXP-Topic perf-run
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3ec42dcfe522
perf: pass limits as a function argument

The function applying the limit has no access to the configuration. Therefore,
some higher layer will have to pass it as argument.

We do this in an independent change to clarify the next change.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -322,7 +322,8 @@  DEFAULTLIMITS = (
     (10.0, 3),
 )
 
-def _timer(fm, func, setup=None, title=None, displayall=False):
+def _timer(fm, func, setup=None, title=None, displayall=False,
+           limits=DEFAULTLIMITS):
     gc.collect()
     results = []
     begin = util.timer()
@@ -338,7 +339,7 @@  def _timer(fm, func, setup=None, title=N
         cstop = util.timer()
         # Look for a stop condition.
         elapsed = cstop - begin
-        for t, mincount in DEFAULTLIMITS:
+        for t, mincount in limits:
             if elapsed >= t and count >= mincount:
                 keepgoing = False
                 break