Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'iadams'
- import sys
- import pika
- import time
- # Creates a connection we can use to talk to the rabbit MQ broker
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- 'localhost'))
- channel = connection.channel()
- # Producers can declare 'channels' to rabbit MQ
- channel.exchange_declare(exchange='logs',
- type='fanout')
- num_times = int(sys.argv[1])
- start = time.time()
- for x in range(num_times):
- time_per_message = time.time
- # Send the message, note empty exchange.
- channel.basic_publish(exchange='logs',
- routing_key='',
- body='Message')
- # close out the connection
- connection.close()
- end = time.time()
- runtime = end - start
- ops = (num_times*1.0)/runtime
- print "Total Run-Time: %f " % runtime
- print "Output Per Second: %f" % ops
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement