<s> from socket import * <EOL> import time <EOL> import sys <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> MSGSIZE = int ( sys . argv [ <NUM_LIT:1> ] ) <EOL> else : <EOL> MSGSIZE = <NUM_LIT:1000> <EOL> msg = b'<STR_LIT:x>' * MSGSIZE <EOL> def run_test ( n ) : <EOL> sock = socket ( AF_INET , SOCK_STREAM ) <EOL> sock . connect ( ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> while n > <NUM_LIT:0> : <EOL> sock . sendall ( msg ) <EOL> nrecv = <NUM_LIT:0> <EOL> while nrecv < MSGSIZE : <EOL> resp = sock . recv ( MSGSIZE ) <EOL> if not resp : <EOL> raise SystemExit ( ) <EOL> nrecv += len ( resp ) <EOL> n -= <NUM_LIT:1> <EOL> NMESSAGES = <NUM_LIT> <EOL> print ( '<STR_LIT>' , NMESSAGES , '<STR_LIT>' ) <EOL> start = time . time ( ) <EOL> run_test ( NMESSAGES ) <EOL> end = time . time ( ) <EOL> duration = end - start <EOL> print ( NMESSAGES , '<STR_LIT>' , duration ) <EOL> print ( NMESSAGES / duration , '<STR_LIT>' ) </s>
