Skip to content

Instantly share code, notes, and snippets.

@seeingidog
Created May 16, 2011 04:28
Show Gist options
  • Save seeingidog/973940 to your computer and use it in GitHub Desktop.
Save seeingidog/973940 to your computer and use it in GitHub Desktop.
benchmark: dm-redis-adapter vs. ohm
require 'benchmark'
require 'ohm'
require 'datamapper'
require 'dm-redis-adapter'
Ohm.connect
DataMapper.setup(:default, {:adapter => "redis"})
class DMUser
include DataMapper::Resource
property :id, Serial
property :username, String
property :email, String
end
class OhmUser < Ohm::Model
attribute :username
attribute :email
end
n = 500
Benchmark.bm do |x|
x.report("Datamapper creates") {
n.times do
DMUser.create(:username => "ian", :email => 'ian@ruby-code.com').save!
end
}
x.report("Ohm creates") {
n.times do
OhmUser.create(:username => "ian", :email => 'ian@ruby-code.com').save
end
}
x.report("Datamapper reads") {
n.times do
DMUser.all
end
}
x.report("Ohm reads") {
n.times do
OhmUser.all
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment