Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mloughran/202156 to your computer and use it in GitHub Desktop.
Save mloughran/202156 to your computer and use it in GitHub Desktop.
BEANSTALK_13 = '/opt/local/bin/beanstalkd'
BEANSTALK_14 = '/usr/local/bin/beanstalkd'
n = 100000
require 'rubygems'
require 'beanstalk-client'
require 'benchmark'
def teardown
system "killall beanstalkd"
sleep 0.2
end
test_put = lambda { |x, beanstalk|
x.report("put") do
n.times { beanstalk.put('hello') }
end
}
puts
puts "Test beanstalk 1.3"
puts
system "#{BEANSTALK_13} -p 10001 &"
sleep 0.2
beanstalk = Beanstalk::Pool.new(['localhost:10001'])
Benchmark.bm do |x|
test_put.call(x, beanstalk)
end
teardown
puts
puts "Test beanstalk 1.4 without persistence"
puts
system "#{BEANSTALK_14} -p 10001 -d"
sleep 0.2
beanstalk = Beanstalk::Pool.new(['localhost:10001'])
Benchmark.bm do |x|
test_put.call(x, beanstalk)
end
teardown
puts
puts "Test beanstalk 1.4 with persistence"
puts
system "#{BEANSTALK_14} -p 10001 -b /tmp/bean -d"
sleep 0.2
beanstalk = Beanstalk::Pool.new(['localhost:10001'])
Benchmark.bm do |x|
test_put.call(x, beanstalk)
end
teardown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment