def main(ports, instances, count, size, handshake=None): hosts = [('localhost', port) for port in ports] message_count = instances * count * len(hosts) data_size = message_count * size total_data_size = 2 * data_size messengers = [] try: start_time = time.time() tasklets = [] finish_queue = Queue() for i in xrange(instances): messengers = [(id(host), Messenger(host, handshake=handshake)) for host in hosts] for token, messenger in messengers: messenger.connect() coio.stackless.schedule() tasklets.append( coio.stackless.tasklet(invoke)(messengers, count, size, finish_queue)) for i in xrange(instances): finish_queue.pop() end_time = time.time() elapsed_time = end_time - start_time logging.info('time: %.2f seconds', elapsed_time) logging.info('%.2f messages/s' % (float(message_count) / elapsed_time)) logging.info('%.2f MB data' % (float(total_data_size) / (1024 * 1024))) logging.info('%.2f MB/s' % (float(total_data_size) / (1024 * 1024 * elapsed_time))) finally: for token, messenger in messengers: messenger.close()
def main(ports, instances, count, size, handshake=None): hosts = [('localhost', port) for port in ports] message_count = instances * count * len(hosts) data_size = message_count * size total_data_size = 2 * data_size messengers = [] try: start_time = time.time() tasklets = [] finish_queue = Queue() for i in xrange(instances): messengers = [(id(host), Messenger(host, handshake=handshake)) for host in hosts] for token, messenger in messengers: messenger.connect() coio.stackless.schedule() tasklets.append(coio.stackless.tasklet(invoke)(messengers, count, size, finish_queue)) for i in xrange(instances): finish_queue.pop() end_time = time.time() elapsed_time = end_time - start_time logging.info('time: %.2f seconds', elapsed_time) logging.info('%.2f messages/s' % (float(message_count) / elapsed_time)) logging.info('%.2f MB data' % (float(total_data_size) / (1024*1024))) logging.info('%.2f MB/s' % (float(total_data_size) / (1024*1024 * elapsed_time))) finally: for token, messenger in messengers: messenger.close()
def main(): s = coio.nbsocket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', 5555)) c = Channel(s) N = 200000 M = 16 message = '.' * M byte_count = len(message) * N f = Queue() coio.stackless.tasklet(rawsocket_echoclient_core.sender)(c, message, N, f) coio.stackless.tasklet(rawsocket_echoclient_core.receiver)(c, N, f) start_time = timer() f.pop() f.pop() end_time = timer() diff_time = end_time - start_time print 'Transmission time: %fs' % diff_time print '%.2f messages/s, %.2f MB/s' % (float(N*2) / diff_time, (float(byte_count*2) / 2**20) / diff_time)
def main(): s = coio.nbsocket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', 5555)) c = Channel(s) N = 200000 M = 16 message = '.' * M byte_count = len(message) * N f = Queue() coio.stackless.tasklet(rawsocket_echoclient_core.sender)(c, message, N, f) coio.stackless.tasklet(rawsocket_echoclient_core.receiver)(c, N, f) start_time = timer() f.pop() f.pop() end_time = timer() diff_time = end_time - start_time print 'Transmission time: %fs' % diff_time print '%.2f messages/s, %.2f MB/s' % (float(N * 2) / diff_time, (float(byte_count * 2) / 2**20) / diff_time)