##// END OF EJS Templates
perf: add a `setup` argument to run code outside of the timed section...
Boris Feld -
r40716:9d88ae5c default
parent child Browse files
Show More
@@ -275,7 +275,7 b' def gettimer(ui, opts=None):'
275 275 displayall = ui.configbool(b"perf", b"all-timing", False)
276 276 return functools.partial(_timer, fm, displayall=displayall), fm
277 277
278 def stub_timer(fm, func, title=None):
278 def stub_timer(fm, func, setup=None, title=None):
279 279 func()
280 280
281 281 @contextlib.contextmanager
@@ -289,12 +289,14 b' def timeone():'
289 289 a, b = ostart, ostop
290 290 r.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
291 291
292 def _timer(fm, func, title=None, displayall=False):
292 def _timer(fm, func, setup=None, title=None, displayall=False):
293 293 gc.collect()
294 294 results = []
295 295 begin = util.timer()
296 296 count = 0
297 297 while True:
298 if setup is not None:
299 setup()
298 300 with timeone() as item:
299 301 r = func()
300 302 count += 1
General Comments 0
You need to be logged in to leave comments. Login now