Created
January 3, 2012 22:11
-
-
Save paul/1557216 to your computer and use it in GitHub Desktop.
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
| Active Record (3.2.0.rc1) mysql | Active Record (3.2.0.rc1) mysql-2 | Sequel mysql | Sequel mysql-2 | | |
------------------------------------------------------------------------------------------------------------------------------------------- | |
insert x1000 | 0.896 | 0.810 | 0.883 | 0.809 | | |
select 1000 records x1000 | 34.637 | 81.096 | 0.017 | 0.016 | |
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 "active_record" | |
conn = { | |
:adapter => "mysql", | |
:database => "people_test", | |
:socket => "/tmp/mysql.sock", | |
:user => "root" | |
} | |
class ARPerson1 < ActiveRecord::Base | |
set_table_name "people" | |
end | |
ARPerson1.establish_connection(conn) | |
ARPerson1.new # Have AR scan the table before the benchmark | |
ARPerson1.connection.execute("TRUNCATE TABLE people") | |
class ARPerson2 < ActiveRecord::Base | |
set_table_name "people" | |
end | |
ARPerson2.establish_connection(conn.merge(:adapter => "mysql2")) | |
ARPerson2.new # Have AR scan the table before the benchmark | |
require "sequel" | |
conn = { | |
:socket => "/tmp/mysql.sock", | |
:encoding => "utf8", | |
:user => "root", | |
:database => "people_test" | |
} | |
PEOPLE_DB1 = Sequel.mysql(conn) | |
PEOPLE_DB2 = Sequel.mysql2(conn) | |
class SPerson1 < Sequel::Model | |
self.set_dataset PEOPLE_DB1[:people] | |
end | |
SPerson1.new | |
class SPerson2 < Sequel::Model | |
self.set_dataset PEOPLE_DB2[:people] | |
end | |
SPerson2.new | |
require "rbench" | |
RBench.run(1000) do | |
column :times | |
column :active_record_1, :title => "Active Record (#{ActiveRecord::VERSION::STRING}) mysql" | |
column :active_record_2, :title => "Active Record (#{ActiveRecord::VERSION::STRING}) mysql-2" | |
column :sequel_1, :title => "Sequel mysql" | |
column :sequel_2, :title => "Sequel mysql-2" | |
#column :diff, :title => "AR/Seq", :compare => [:active_record, :sequel] | |
report "insert" do | |
active_record_1 do | |
ARPerson1.create!(:email => "foo#{Time.now.to_f}@email.test") | |
end | |
active_record_2 do | |
ARPerson2.create!(:email => "foo#{Time.now.to_f}@email.test") | |
end | |
sequel_1 do | |
SPerson1.create(:email => "foo#{Time.now.to_f}@email.test") | |
end | |
sequel_2 do | |
SPerson2.create(:email => "foo#{Time.now.to_f}@email.test") | |
end | |
end | |
report "select 1000 records" do | |
active_record_1 do | |
ARPerson1.where("created_at < ?", Time.now).to_a | |
end | |
active_record_2 do | |
ARPerson2.where("created_at < ?", Time.now).to_a | |
end | |
sequel_1 do | |
SPerson1.where("created_at < ?", Time.now) | |
end | |
sequel_2 do | |
SPerson2.where("created_at < ?", Time.now) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment