Skip to content

Commit

Permalink
Merge remote branch 'lpetre/master'
Browse files Browse the repository at this point in the history
* lpetre/master:
  * making benchmarks friendly to missing backends
  * DM performance improvements
  • Loading branch information
bkeepers committed Apr 8, 2010
2 parents 91cbb24 + 2ddebdb commit be12e60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@

Delayed::Worker.logger = Logger.new('/dev/null')

BACKENDS = []
Dir.glob("#{File.dirname(__FILE__)}/spec/setup/*.rb") do |backend|
begin
backend = File.basename(backend, '.rb')
require "spec/setup/#{backend}"
BACKENDS << backend.to_sym
rescue LoadError
puts "Unable to load #{backend} backend! #{$!}"
end
end


Benchmark.bm(10) do |x|
[:active_record, :mongo_mapper, :data_mapper].each do |backend|
BACKENDS.each do |backend|
require "spec/setup/#{backend}"
Delayed::Worker.backend = backend

Expand Down
5 changes: 3 additions & 2 deletions lib/delayed/backend/data_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Job
property :id, Serial
property :priority, Integer, :default => 0, :index => :run_at_priority
property :attempts, Integer, :default => 0
property :handler, Text
property :handler, Text, :lazy => false
property :run_at, Time, :index => :run_at_priority
property :locked_at, Time
property :locked_at, Time, :index => true
property :locked_by, String
property :failed_at, Time
property :last_error, Text
Expand Down Expand Up @@ -69,6 +69,7 @@ def self.clear_locks!(worker_name)
# Lock this job for this worker.
# Returns true if we have the lock, false otherwise.
def lock_exclusively!(max_run_time, worker = worker_name)

now = self.class.db_time_now
overtime = now - max_run_time

Expand Down

0 comments on commit be12e60

Please sign in to comment.