Created
April 13, 2014 19:39
-
-
Save kristaps/10599120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import rabbitpy | |
import time | |
MSG_COUNT = 100 | |
conn = rabbitpy.Connection('amqp://guest:guest@localhost/%2F?locale=en_US.UTF-8') | |
chan = conn.channel() | |
x = rabbitpy.Exchange(chan, 'amq.direct', durable=True) | |
x.declare() | |
q = rabbitpy.Queue(chan, 'get_test', auto_delete=True, exclusive=True) | |
q.declare() | |
q.bind(x, 'get_test') | |
for i in xrange(MSG_COUNT): | |
rabbitpy.Message(chan, str(i)).publish(x, 'get_test') | |
started_at = time.time() | |
msgs_processed = 0 | |
while True: | |
get_started_at = time.time() | |
msg = q.get(False) | |
get_finished_at = time.time() | |
if msg is None: | |
break | |
print msg.body, "%.2f" % (get_finished_at - get_started_at) | |
msgs_processed += 1 | |
duration = time.time() - started_at | |
print "%.2f msgs/s" % (1.0 / (duration / float(MSG_COUNT))) | |
conn.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment