Advertisement
Guest User

Untitled

a guest
Nov 19th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. __author__ = 'iadams'
  2. import sys
  3. import pika
  4. import time
  5.  
  6.  
  7. # Creates a connection we can use to talk to the rabbit MQ broker
  8. connection = pika.BlockingConnection(pika.ConnectionParameters(
  9.                'localhost'))
  10. channel = connection.channel()
  11.  
  12. # Producers can declare 'channels' to rabbit MQ
  13. channel.exchange_declare(exchange='logs',
  14.                          type='fanout')
  15.  
  16.  
  17. num_times = int(sys.argv[1])
  18.  
  19. start = time.time()
  20. for x in range(num_times):
  21.  
  22.     time_per_message = time.time
  23.     # Send the message, note empty exchange.
  24.     channel.basic_publish(exchange='logs',
  25.                       routing_key='',
  26.                       body='Message')
  27.  
  28.     # close out the connection
  29. connection.close()
  30.  
  31. end = time.time()
  32.  
  33. runtime = end - start
  34. ops = (num_times*1.0)/runtime
  35.  
  36. print "Total Run-Time: %f " % runtime
  37. print "Output Per Second: %f" % ops
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement