Skip to content

Instantly share code, notes, and snippets.

@Fitzsimmons
Created February 27, 2012 20:09
Show Gist options
  • Save Fitzsimmons/1926694 to your computer and use it in GitHub Desktop.
Save Fitzsimmons/1926694 to your computer and use it in GitHub Desktop.
Bunny benchmarking
require 'benchmark'
require 'rubygems'
require 'bunny'
m = "<event>
<string1>123456790123456790123456790123456790</string1>
<string2>123456790123456790123456790123456790</string2>
<string2>123456790123456790123456790123456790</string2>
<string2>123456790123456790123456790123456790</string2>
</event>"
b = Bunny.new
b.start
b.tx_select
Benchmark.bm do |x|
x.report do
q = b.queue('cpi-test-durable', :durable => true)
direct_exchange = b.exchange('')
10000.times do
direct_exchange.publish(m, :key => "cpi-test-durable")
b.tx_commit
end
end
end
b.stop
require 'benchmark'
require 'rubygems'
require 'bunny'
b = Bunny.new
b.start
b.tx_select
q = b.queue('cpi-test-durable', :durable => true)
Benchmark.bm do |x|
x.report do
while true
msg = q.pop(:ack => true)
break if msg[:payload] == :queue_empty
q.ack
b.tx_commit
end
end
end
b.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment