Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wevtimoteo/3cea18890e9b6611e4e2fe04c766fa6d to your computer and use it in GitHub Desktop.
Save wevtimoteo/3cea18890e9b6611e4e2fe04c766fa6d to your computer and use it in GitHub Desktop.
benchmark: dm-redis-adapter vs. ohm
require 'benchmark/ips'
require 'ohm'
require 'dm-core'
require 'dm-redis-adapter'
Ohm.redis = Redic.new("redis://127.0.0.1:6379")
DataMapper.setup(:default, {:adapter => "redis"})
class DMUser
include DataMapper::Resource
property :id, Serial
property :username, String
property :email, String
end
DataMapper.finalize
class OhmUser < Ohm::Model
attribute :username
attribute :email
end
n = 500
Benchmark.ips do |x|
x.report("Datamapper creates") {
DMUser.create(:username => "ian", :email => 'ian@ruby-code.com').save!
}
x.report("Ohm creates") {
OhmUser.create(:username => "ian", :email => 'ian@ruby-code.com').save
}
x.report("Datamapper reads") {
DMUser.all
}
x.report("Ohm reads") {
OhmUser.all
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment