<s> """<STR_LIT>""" <EOL> import time <EOL> import logging <EOL> import sys <EOL> import os <EOL> import cProfile as profile <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT>" ) <EOL> import snakemq <EOL> import snakemq . link <EOL> import snakemq . packeter <EOL> DATA_SIZE = <NUM_LIT:5> <EOL> COUNT = <NUM_LIT> <EOL> PORT = <NUM_LIT> <EOL> def srv ( ) : <EOL> s = snakemq . link . Link ( ) <EOL> container = { "<STR_LIT>" : None , "<STR_LIT:count>" : <NUM_LIT:0> } <EOL> def on_connect ( conn_id ) : <EOL> container [ "<STR_LIT>" ] = time . time ( ) <EOL> def on_packet_recv ( conn_id , packet ) : <EOL> assert len ( packet ) == DATA_SIZE <EOL> container [ "<STR_LIT:count>" ] += <NUM_LIT:1> <EOL> def on_disconnect ( conn_id ) : <EOL> diff = time . time ( ) - container [ "<STR_LIT>" ] <EOL> print "<STR_LIT>" % ( DATA_SIZE * COUNT / diff / <NUM_LIT> ** <NUM_LIT:2> , <EOL> COUNT / diff ) <EOL> s . stop ( ) <EOL> s . add_listener ( ( "<STR_LIT>" , PORT ) ) <EOL> tr = snakemq . packeter . Packeter ( s ) <EOL> tr . on_connect = on_connect <EOL> tr . on_packet_recv = on_packet_recv <EOL> tr . on_disconnect = on_disconnect <EOL> s . loop ( ) <EOL> s . cleanup ( ) <EOL> assert container [ "<STR_LIT:count>" ] == COUNT <EOL> def cli ( ) : <EOL> s = snakemq . link . Link ( ) <EOL> container = { "<STR_LIT:count>" : <NUM_LIT:0> } <EOL> def on_connect ( conn_id ) : <EOL> for i in xrange ( COUNT ) : <EOL> tr . send_packet ( conn_id , "<STR_LIT:x>" * DATA_SIZE ) <EOL> def on_packet_sent ( conn_id , packet_id ) : <EOL> container [ "<STR_LIT:count>" ] += <NUM_LIT:1> <EOL> if container [ "<STR_LIT:count>" ] == COUNT : <EOL> s . stop ( ) <EOL> s . add_connector ( ( "<STR_LIT:localhost>" , PORT ) ) <EOL> tr = snakemq . packeter . Packeter ( s ) <EOL> tr . on_connect = on_connect <EOL> tr . on_packet_sent = on_packet_sent <EOL> s . loop ( ) <EOL> s . cleanup ( ) <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> logger . setLevel ( logging . ERROR ) <EOL> if os . fork ( ) > <NUM_LIT:0> : <EOL> srv ( ) <EOL> else : <EOL> cli ( ) </s>
