-
-
Save betamatt/724093 to your computer and use it in GitHub Desktop.
Mult-worker DJ benchmark
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
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