<s> """<STR_LIT>""" <EOL> import re <EOL> from perfkitbenchmarker import configs <EOL> from perfkitbenchmarker import flags <EOL> from perfkitbenchmarker import sample <EOL> from perfkitbenchmarker . linux_packages import docker <EOL> flags . DEFINE_string ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> flags . DEFINE_integer ( '<STR_LIT>' , <EOL> <NUM_LIT> , <EOL> '<STR_LIT>' ) <EOL> FLAGS = flags . FLAGS <EOL> BENCHMARK_NAME = '<STR_LIT>' <EOL> BENCHMARK_CONFIG = """<STR_LIT>""" <EOL> def GetConfig ( user_config ) : <EOL> return configs . LoadConfig ( BENCHMARK_CONFIG , user_config , BENCHMARK_NAME ) <EOL> def Prepare ( benchmark_spec ) : <EOL> """<STR_LIT>""" <EOL> server_vm = benchmark_spec . vm_groups [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> client_vm = benchmark_spec . vm_groups [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> for vm in ( server_vm , client_vm ) : <EOL> if not docker . IsInstalled ( vm ) : <EOL> vm . Install ( '<STR_LIT>' ) <EOL> server_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> server_vm . RemoteCommand ( "<STR_LIT>" <EOL> "<STR_LIT>" % client_vm . internal_ip ) <EOL> server_vm . RemoteCommand ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> FLAGS . cloudsuite_data_caching_memcached_flags ) <EOL> client_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> client_vm . RemoteCommand ( "<STR_LIT>" <EOL> "<STR_LIT>" % server_vm . internal_ip ) <EOL> def _ParseOutput ( output_str ) : <EOL> numbers = [ float ( f ) for f in re . findall ( r"<STR_LIT>" , <EOL> "<STR_LIT:U+0020>" . join ( output_str . splitlines ( <NUM_LIT:1> ) [ - <NUM_LIT:4> : ] ) ) ] <EOL> results = [ ] <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> numbers [ <NUM_LIT:1> ] , "<STR_LIT>" ) ) <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> numbers [ <NUM_LIT:7> ] , "<STR_LIT>" ) ) <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> numbers [ <NUM_LIT:8> ] , "<STR_LIT>" ) ) <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> numbers [ <NUM_LIT:9> ] , "<STR_LIT>" ) ) <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> numbers [ <NUM_LIT:10> ] , "<STR_LIT>" ) ) <EOL> req_rems = numbers [ <NUM_LIT:15> : - <NUM_LIT:1> ] <EOL> results . append ( sample . Sample ( "<STR_LIT>" , <EOL> sum ( req_rems ) / len ( req_rems ) , "<STR_LIT>" ) ) <EOL> return results <EOL> def Run ( benchmark_spec ) : <EOL> """<STR_LIT>""" <EOL> client_vm = benchmark_spec . vm_groups [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> benchmark_cmd = ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> FLAGS . cloudsuite_data_caching_rps ) <EOL> stdout , _ = client_vm . RemoteCommand ( benchmark_cmd , should_log = True ) <EOL> return _ParseOutput ( stdout ) <EOL> def Cleanup ( benchmark_spec ) : <EOL> """<STR_LIT>""" <EOL> server_vm = benchmark_spec . vm_groups [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> client_vm = benchmark_spec . vm_groups [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> server_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> server_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> server_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> client_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> client_vm . RemoteCommand ( '<STR_LIT>' ) <EOL> client_vm . RemoteCommand ( '<STR_LIT>' ) </s>
