Skip to content

Instantly share code, notes, and snippets.

@betamatt
Forked from bkeepers/benchmarks_multi.rb
Created December 1, 2010 19:48
Show Gist options
  • Save betamatt/724093 to your computer and use it in GitHub Desktop.
Save betamatt/724093 to your computer and use it in GitHub Desktop.
Mult-worker DJ benchmark
require 'spec/spec_helper'
require 'logger'
require 'benchmark'
workers = 20
puts "#{workers} workers"
#Delayed::Job.logger = Logger.new('/tmp/delayed_job.log')
pids = []
Benchmark.bm(10) do |x|
Delayed::Job.delete_all
(1000...5001).step(500).each do |n|
n.times { "foo".delay.length }
x.report("#{n} jobs") do
Delayed::Worker.backend.before_fork
pids = []
workers.times do
pids << fork do
Delayed::Worker.backend.after_fork
while Delayed::Job.first do
Delayed::Worker.new(:quiet => true).work_off(n)
end
end
end
# No idea if this works right
trap('TERM') do
Process.kill(*pids)
Process.waitall
exit(1)
end
Process.waitall
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment