<s> from __future__ import division , absolute_import , print_function , unicode_literals <EOL> import os <EOL> from nanomsg_wrappers import set_wrapper_choice , get_default_for_platform <EOL> WRAPPER = os . environ . get ( '<STR_LIT>' , get_default_for_platform ( ) ) <EOL> set_wrapper_choice ( WRAPPER ) <EOL> from nanomsg import ( <EOL> PAIR , <EOL> Socket , <EOL> create_message_buffer <EOL> ) <EOL> from nanomsg . wrapper import ( <EOL> nn_send , <EOL> nn_recv <EOL> ) <EOL> SOCKET_ADDRESS = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> import time <EOL> BUFFER_SIZE = eval ( os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) ) <EOL> msg = create_message_buffer ( BUFFER_SIZE , <NUM_LIT:0> ) <EOL> DURATION = <NUM_LIT:10> <EOL> print ( ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( BUFFER_SIZE , WRAPPER , SOCKET_ADDRESS ) ) <EOL> count = <NUM_LIT:0> <EOL> start_t = time . time ( ) <EOL> with Socket ( PAIR ) as socket1 : <EOL> with Socket ( PAIR ) as socket2 : <EOL> socket1 . bind ( SOCKET_ADDRESS ) <EOL> socket2 . connect ( SOCKET_ADDRESS ) <EOL> while time . time ( ) < start_t + DURATION : <EOL> c = chr ( count % <NUM_LIT:255> ) <EOL> memoryview ( msg ) [ <NUM_LIT:0> ] = c <EOL> socket1 . send ( msg ) <EOL> res = socket2 . recv ( msg ) <EOL> assert res [ <NUM_LIT:0> ] == c <EOL> count += <NUM_LIT:1> <EOL> stop_t = time . time ( ) <EOL> print ( '<STR_LIT>' % ( ( count * BUFFER_SIZE ) / ( stop_t - start_t ) / <NUM_LIT> , ) ) <EOL> count = <NUM_LIT:0> <EOL> start_t = time . time ( ) <EOL> with Socket ( PAIR ) as socket1 : <EOL> with Socket ( PAIR ) as socket2 : <EOL> socket1 . bind ( SOCKET_ADDRESS ) <EOL> socket2 . connect ( SOCKET_ADDRESS ) <EOL> while time . time ( ) < start_t + DURATION : <EOL> nn_send ( socket1 . fd , msg , <NUM_LIT:0> ) <EOL> nn_recv ( socket2 . fd , msg , <NUM_LIT:0> ) <EOL> count += <NUM_LIT:1> <EOL> stop_t = time . time ( ) <EOL> print ( '<STR_LIT>' % ( ( count * BUFFER_SIZE ) / ( stop_t - start_t ) / <NUM_LIT> , ) ) </s>
