Created
May 16, 2011 04:28
-
-
Save seeingidog/973940 to your computer and use it in GitHub Desktop.
benchmark: dm-redis-adapter vs. ohm
This file contains hidden or 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' | |
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 => '[email protected]').save! | |
end | |
} | |
x.report("Ohm creates") { | |
n.times do | |
OhmUser.create(:username => "ian", :email => '[email protected]').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