Show More
@@ -315,12 +315,20 b' def timeone():' | |||||
315 | a, b = ostart, ostop |
|
315 | a, b = ostart, ostop | |
316 | r.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) |
|
316 | r.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) | |
317 |
|
317 | |||
|
318 | ||||
|
319 | # list of stop condition (elapsed time, minimal run count) | |||
|
320 | DEFAULTLIMITS = ( | |||
|
321 | (3.0, 100), | |||
|
322 | (10.0, 3), | |||
|
323 | ) | |||
|
324 | ||||
318 | def _timer(fm, func, setup=None, title=None, displayall=False): |
|
325 | def _timer(fm, func, setup=None, title=None, displayall=False): | |
319 | gc.collect() |
|
326 | gc.collect() | |
320 | results = [] |
|
327 | results = [] | |
321 | begin = util.timer() |
|
328 | begin = util.timer() | |
322 | count = 0 |
|
329 | count = 0 | |
323 | while True: |
|
330 | keepgoing = True | |
|
331 | while keepgoing: | |||
324 | if setup is not None: |
|
332 | if setup is not None: | |
325 | setup() |
|
333 | setup() | |
326 | with timeone() as item: |
|
334 | with timeone() as item: | |
@@ -328,10 +336,12 b' def _timer(fm, func, setup=None, title=N' | |||||
328 | count += 1 |
|
336 | count += 1 | |
329 | results.append(item[0]) |
|
337 | results.append(item[0]) | |
330 | cstop = util.timer() |
|
338 | cstop = util.timer() | |
331 | if cstop - begin > 3 and count >= 100: |
|
339 | # Look for a stop condition. | |
332 | break |
|
340 | elapsed = cstop - begin | |
333 | if cstop - begin > 10 and count >= 3: |
|
341 | for t, mincount in DEFAULTLIMITS: | |
334 | break |
|
342 | if elapsed >= t and count >= mincount: | |
|
343 | keepgoing = False | |||
|
344 | break | |||
335 |
|
345 | |||
336 | formatone(fm, results, title=title, result=r, |
|
346 | formatone(fm, results, title=title, result=r, | |
337 | displayall=displayall) |
|
347 | displayall=displayall) |
General Comments 0
You need to be logged in to leave comments.
Login now