<s> import gc <EOL> import timeit <EOL> import random <EOL> def measure_best ( repeat , iters , <EOL> common_setup = '<STR_LIT>' , <EOL> common_cleanup = '<STR_LIT>' , <EOL> * funcs ) : <EOL> funcs = list ( funcs ) <EOL> results = dict ( [ ( f , [ ] ) for f in funcs ] ) <EOL> for i in xrange ( repeat ) : <EOL> random . shuffle ( funcs ) <EOL> for func in funcs : <EOL> gc . collect ( ) <EOL> t = timeit . Timer ( func , setup = common_setup ) <EOL> results [ func ] . append ( t . timeit ( iters ) ) <EOL> common_cleanup ( ) <EOL> best_results = { } <EOL> for func , times in results . iteritems ( ) : <EOL> best_results [ func ] = min ( times ) <EOL> return best_results </s>
