<s> """<STR_LIT>""" <EOL> import json <EOL> import logging <EOL> from perfkitbenchmarker import configs <EOL> from perfkitbenchmarker import flags <EOL> from perfkitbenchmarker . linux_packages import fio <EOL> LOGGING = '<STR_LIT>' <EOL> DATABASE = '<STR_LIT>' <EOL> STREAMING = '<STR_LIT>' <EOL> flags . DEFINE_enum ( '<STR_LIT>' , LOGGING , <EOL> [ LOGGING , DATABASE , STREAMING ] , <EOL> '<STR_LIT>' ) <EOL> flags . DEFINE_list ( '<STR_LIT>' , [ ] , '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> flags . DEFINE_integer ( '<STR_LIT>' , <NUM_LIT:0> , <EOL> '<STR_LIT>' ) <EOL> FLAGS = flags . FLAGS <EOL> BENCHMARK_NAME = '<STR_LIT>' <EOL> BENCHMARK_CONFIG = """<STR_LIT>""" <EOL> DESCRIPTION = '<STR_LIT:description>' <EOL> METHOD = '<STR_LIT>' <EOL> DEFAULT_IODEPTH = <NUM_LIT:8> <EOL> DEFAULT_DATABASE_SIMULATION_IODEPTH_LIST = [ <NUM_LIT:16> , <NUM_LIT:64> ] <EOL> DEFAULT_STREAMING_SIMULATION_IODEPTH_LIST = [ <NUM_LIT:1> , <NUM_LIT:16> ] <EOL> LATENCY_REGEX = r'<STR_LIT>' <EOL> BANDWIDTH_REGEX = r'<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> vms = benchmark_spec . vms <EOL> vm = vms [ <NUM_LIT:0> ] <EOL> logging . info ( '<STR_LIT>' , vm ) <EOL> vm . Install ( '<STR_LIT>' ) <EOL> def UpdateWorkloadMetadata ( results ) : <EOL> """<STR_LIT>""" <EOL> for result in results : <EOL> result . metadata . update ( { '<STR_LIT>' : FLAGS . workload_mode } ) <EOL> def RunSimulatedLogging ( vm ) : <EOL> """<STR_LIT>""" <EOL> test_size = vm . total_memory_kb <EOL> cmd = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( vm . GetScratchDir ( ) , <EOL> test_size , <EOL> DEFAULT_IODEPTH ) <EOL> if FLAGS . maxjobs : <EOL> cmd += '<STR_LIT>' % FLAGS . maxjobs <EOL> cmd += ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( test_size / <NUM_LIT:10> ) <EOL> logging . info ( '<STR_LIT>' , LOGGING ) <EOL> res , _ = vm . RemoteCommand ( '<STR_LIT>' % ( fio . FIO_CMD_PREFIX , cmd ) , <EOL> should_log = True ) <EOL> results = fio . ParseResults ( fio . FioParametersToJob ( cmd ) , json . loads ( res ) ) <EOL> UpdateWorkloadMetadata ( results ) <EOL> return results <EOL> def RunSimulatedDatabase ( vm ) : <EOL> """<STR_LIT>""" <EOL> test_size = min ( vm . total_memory_kb / <NUM_LIT:10> , <NUM_LIT> ) <EOL> iodepth_list = FLAGS . iodepth_list or DEFAULT_DATABASE_SIMULATION_IODEPTH_LIST <EOL> results = [ ] <EOL> for depth in iodepth_list : <EOL> cmd = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( vm . GetScratchDir ( ) , <EOL> depth , <EOL> test_size ) <EOL> if FLAGS . maxjobs : <EOL> cmd += '<STR_LIT>' % FLAGS . maxjobs <EOL> cmd += ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> logging . info ( '<STR_LIT>' , DATABASE , depth ) <EOL> res , _ = vm . RemoteCommand ( '<STR_LIT>' % ( fio . FIO_CMD_PREFIX , cmd ) , <EOL> should_log = True ) <EOL> results . extend ( <EOL> fio . ParseResults ( fio . FioParametersToJob ( cmd ) , json . loads ( res ) ) ) <EOL> UpdateWorkloadMetadata ( results ) <EOL> return results <EOL> def RunSimulatedStreaming ( vm ) : <EOL> """<STR_LIT>""" <EOL> test_size = min ( vm . total_memory_kb / <NUM_LIT:10> , <NUM_LIT> ) <EOL> iodepth_list = FLAGS . iodepth_list or DEFAULT_STREAMING_SIMULATION_IODEPTH_LIST <EOL> results = [ ] <EOL> for depth in iodepth_list : <EOL> cmd = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( vm . GetScratchDir ( ) , <EOL> depth , <EOL> test_size ) <EOL> if FLAGS . maxjobs : <EOL> cmd += '<STR_LIT>' % FLAGS . maxjobs <EOL> cmd += ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> logging . info ( '<STR_LIT>' , STREAMING ) <EOL> res , _ = vm . RemoteCommand ( '<STR_LIT>' % ( fio . FIO_CMD_PREFIX , cmd ) , <EOL> should_log = True ) <EOL> results . extend ( <EOL> fio . ParseResults ( fio . FioParametersToJob ( cmd ) , json . loads ( res ) ) ) <EOL> UpdateWorkloadMetadata ( results ) <EOL> return results <EOL> RUN_SCENARIO_FUNCTION_DICT = { <EOL> LOGGING : { DESCRIPTION : '<STR_LIT>' , METHOD : RunSimulatedLogging } , <EOL> DATABASE : { DESCRIPTION : '<STR_LIT>' , METHOD : RunSimulatedDatabase } , <EOL> STREAMING : { DESCRIPTION : '<STR_LIT>' , <EOL> METHOD : RunSimulatedStreaming } } <EOL> def Run ( benchmark_spec ) : <EOL> """<STR_LIT>""" <EOL> logging . info ( '<STR_LIT>' , FLAGS . workload_mode ) <EOL> vms = benchmark_spec . vms <EOL> vm = vms [ <NUM_LIT:0> ] <EOL> return RUN_SCENARIO_FUNCTION_DICT [ FLAGS . workload_mode ] [ METHOD ] ( vm ) <EOL> def Cleanup ( benchmark_spec ) : <EOL> """<STR_LIT>""" <EOL> vms = benchmark_spec . vms <EOL> vm = vms [ <NUM_LIT:0> ] <EOL> logging . info ( '<STR_LIT>' , vm ) <EOL> vm . RemoveFile ( vm . GetScratchDir ( ) + '<STR_LIT>' ) </s>
