Skip to content

Instantly share code, notes, and snippets.

@dbackeus
Created February 23, 2010 16:11
Show Gist options
  • Save dbackeus/312345 to your computer and use it in GitHub Desktop.
Save dbackeus/312345 to your computer and use it in GitHub Desktop.
# ./test/resque_benchmark.rb
require File.join(File.dirname(__FILE__), 'test_helper')
require 'benchmark'
class SimpleJob
def self.perform
"Awesome"
end
end
class Job1 < SimpleJob
@queue = :queue1
end
class Job2 < SimpleJob
@queue = :queue2
end
class Job3 < SimpleJob
@queue = :queue3
end
class Job4 < SimpleJob
@queue = :queue4
end
class Array
def rand
self[Kernel.rand(length)]
end
end
a = [0,1,2,3,4,5,6]
Resque.redis.flush_all
result = Benchmark.measure do
[Job1, Job2, Job3, Job4, Job3, Job2, Job1].each do |job|
10_000.times do
Resque.enqueue(job)
end
end
end
puts "Enqueuing"
puts result
worker = Resque::Worker.new("*")
result = Benchmark.measure { worker.work(0) }
puts "Working"
puts result
# With 7 000 entries
#
# Enqueuing
# 1.090000 0.240000 1.330000 ( 2.027309)
# Working
# 4.150000 0.870000 5.030000 ( 7.943047)
# With 70 000 entries
#
# Enqueuing
# 10.840000 2.340000 13.180000 ( 20.469029)
# Working
# 47.680000 9.190000 56.870000 (212.237683)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment