Add python-eventlet package to MOS 8.0 repository
[packages/trusty/python-eventlet.git] / python-eventlet / benchmarks / __init__.py
1 import gc
2 import timeit
3 import random
4
5 from eventlet.support import six
6
7
8 def measure_best(repeat, iters,
9                  common_setup='pass',
10                  common_cleanup='pass',
11                  *funcs):
12     funcs = list(funcs)
13     results = dict([(f, []) for f in funcs])
14
15     for i in six.moves.range(repeat):
16         random.shuffle(funcs)
17         for func in funcs:
18             gc.collect()
19             t = timeit.Timer(func, setup=common_setup)
20             results[func].append(t.timeit(iters))
21             common_cleanup()
22
23     best_results = {}
24     for func, times in six.iteritems(results):
25         best_results[func] = min(times)
26     return best_results