<s> import functools <EOL> import itertools <EOL> import redis <EOL> import sys <EOL> import timeit <EOL> from redis . _compat import izip <EOL> class Benchmark ( object ) : <EOL> ARGUMENTS = ( ) <EOL> def __init__ ( self ) : <EOL> self . _client = None <EOL> def get_client ( self , ** kwargs ) : <EOL> if self . _client is None or kwargs : <EOL> defaults = { <EOL> '<STR_LIT>' : <NUM_LIT:9> <EOL> } <EOL> defaults . update ( kwargs ) <EOL> pool = redis . ConnectionPool ( ** kwargs ) <EOL> self . _client = redis . StrictRedis ( connection_pool = pool ) <EOL> return self . _client <EOL> def setup ( self , ** kwargs ) : <EOL> pass <EOL> def run ( self , ** kwargs ) : <EOL> pass <EOL> def run_benchmark ( self ) : <EOL> group_names = [ group [ '<STR_LIT:name>' ] for group in self . ARGUMENTS ] <EOL> group_values = [ group [ '<STR_LIT>' ] for group in self . ARGUMENTS ] <EOL> for value_set in itertools . product ( * group_values ) : <EOL> pairs = list ( izip ( group_names , value_set ) ) <EOL> arg_string = '<STR_LIT:U+002CU+0020>' . join ( [ '<STR_LIT>' % ( p [ <NUM_LIT:0> ] , p [ <NUM_LIT:1> ] ) for p in pairs ] ) <EOL> sys . stdout . write ( '<STR_LIT>' % arg_string ) <EOL> sys . stdout . flush ( ) <EOL> kwargs = dict ( pairs ) <EOL> setup = functools . partial ( self . setup , ** kwargs ) <EOL> run = functools . partial ( self . run , ** kwargs ) <EOL> t = timeit . timeit ( stmt = run , setup = setup , number = <NUM_LIT:1000> ) <EOL> sys . stdout . write ( '<STR_LIT>' % t ) <EOL> sys . stdout . flush ( ) </s>
