-
-
Save mmplisskin/23dcb1cee94a40df5189ab3789596bde to your computer and use it in GitHub Desktop.
benchmark: dm-redis-adapter vs. ohm
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
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 => '[email protected]').save! | |
} | |
x.report("Ohm creates") { | |
OhmUser.create(:username => "ian", :email => '[email protected]').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