Created
February 23, 2010 16:09
-
-
Save dbackeus/312342 to your computer and use it in GitHub Desktop.
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
# ./test/resque-mongo_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.drop | |
result = Benchmark.measure do | |
[Job1, Job2, Job3, Job4, Job3, Job2, Job1].each do |job| | |
1000.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.250000 0.150000 1.400000 ( 1.403977) | |
# Working | |
# 10.220000 1.020000 11.240000 ( 80.512621) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment