Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'benchmark'
Q = "select * from bet limit 3000"
ARi = Proc.new {
require 'activerecord'
ActiveRecord::Base.establish_connection(:adapter => "postgresql",
:host => "localhost",
:username => "betscan",
:password => "abcd1234",
:database => "betloader")
class BetAR < ActiveRecord::Base
set_table_name "bet"
end
}
DMi = Proc.new {
require 'datamapper'
DataMapper.setup(:default, 'postgres://betscan:abcd1234@localhost/betloader')
class BetDM
include DataMapper::Resource
storage_names[:default] = 'bet'
property :id, Serial
property :time, DateTime
property :bookmaker_id, Integer
property :event_id, Integer
end
}
SQi = Proc.new {
require 'sequel'
DB = Sequel.connect('postgres://betscan:abcd1234@localhost/betloader')
}
Benchmark.bm do |x|
x.report("ARi", &ARi)
x.report("DMi", &DMi)
x.report("SQi", &SQi)
end
ARp = Proc.new {
data = BetAR.find_by_sql Q
#data = ActiveRecord::Base.connection.execute Q
nused = nil
data.each{|e|
nused = "#{e.time}+#{e.id}+#{e.bookmaker_id}+#{e.event_id}"
}
p nused
}
DMp = Proc.new {
data = BetDM.find_by_sql Q
nused = nil
data.each{|e|
nused = "#{e.time}+#{e.id}+#{e.bookmaker_id}+#{e.event_id}"
}
p nused
}
SQp = Proc.new {
data = DB[Q]
nused = nil
data.each{|e|
nused = "#{e[:time]}+#{e[:id]}+#{e[:bookmaker_id]}+#{e[:event_id]}"
}
p nused
}
Benchmark.bm do |x|
x.report("DM", &DMp)
x.report("SQ", &SQp)
x.report("AR", &ARp)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.