Show More
@@ -275,7 +275,7 b' def gettimer(ui, opts=None):' | |||||
275 | displayall = ui.configbool(b"perf", b"all-timing", False) |
|
275 | displayall = ui.configbool(b"perf", b"all-timing", False) | |
276 | return functools.partial(_timer, fm, displayall=displayall), fm |
|
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 | func() |
|
279 | func() | |
280 |
|
280 | |||
281 | @contextlib.contextmanager |
|
281 | @contextlib.contextmanager | |
@@ -289,12 +289,14 b' def timeone():' | |||||
289 | a, b = ostart, ostop |
|
289 | a, b = ostart, ostop | |
290 | r.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) |
|
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 | gc.collect() |
|
293 | gc.collect() | |
294 | results = [] |
|
294 | results = [] | |
295 | begin = util.timer() |
|
295 | begin = util.timer() | |
296 | count = 0 |
|
296 | count = 0 | |
297 | while True: |
|
297 | while True: | |
|
298 | if setup is not None: | |||
|
299 | setup() | |||
298 | with timeone() as item: |
|
300 | with timeone() as item: | |
299 | r = func() |
|
301 | r = func() | |
300 | count += 1 |
|
302 | count += 1 |
General Comments 0
You need to be logged in to leave comments.
Login now