#NEWLINE# def RunNetperf( vm , benchmark_name , servers , result ) : #NEWLINE# #INDENT# 'Spawns netperf on a remote VM, parses results.\n\n  Args:\n    vm: The VM running netperf.\n    benchmark_name: The netperf benchmark to run.\n    servers: VMs running netserver.\n    result: The result variable shared by all threads.\n  ' #NEWLINE# cmd = '' #NEWLINE# if FLAGS . duration_in_seconds : #NEWLINE# #INDENT# cmd_duration_suffix = ( '-l %s' % FLAGS . duration_in_seconds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cmd_duration_suffix = '' #NEWLINE# #UNINDENT# for server in servers : #NEWLINE# #INDENT# if ( vm != server ) : #NEWLINE# #INDENT# cmd += './netperf -t {benchmark_name} -H {server_ip} -i {iterations} {cmd_suffix} & ' . format ( benchmark_name = benchmark_name , server_ip = server . internal_ip , iterations = FLAGS . num_iterations , cmd_suffix = cmd_duration_suffix ) #NEWLINE# #UNINDENT# #UNINDENT# netperf_cmd = '' #NEWLINE# for _ in range ( FLAGS . num_connections ) : #NEWLINE# #INDENT# netperf_cmd += cmd #NEWLINE# #UNINDENT# netperf_cmd += 'wait' #NEWLINE# ( output , _ ) = vm . RemoteCommand ( netperf_cmd ) #NEWLINE# logging . info ( output ) #NEWLINE# match = re . findall ( '(\\d+\\.\\d+)\\s+\\n' , output ) #NEWLINE# value = 0 #NEWLINE# expected_num_match = ( ( len ( servers ) - 1 ) * FLAGS . num_connections ) #NEWLINE# if ( len ( match ) != expected_num_match ) : #NEWLINE# #INDENT# raise errors . Benchmarks . RunError ( ( 'Netserver not reachable. Expecting %s results, got %s.' % ( expected_num_match , len ( match ) ) ) ) #NEWLINE# #UNINDENT# for res in match : #NEWLINE# #INDENT# if ( benchmark_name == 'TCP_RR' ) : #NEWLINE# #INDENT# value += ( ( 1.0 / float ( res ) ) * 1000.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value += float ( res ) #NEWLINE# #UNINDENT# #UNINDENT# with RESULT_LOCK : #NEWLINE# #INDENT# result [ VALUE_INDEX ] += value