Skip to content
Browse files

Revert "update ActiveRecord benchmark to include lazy date/time casting"

This reverts commit 7325884.
  • Loading branch information...
1 parent 9d324c0 commit 90763cea1a0c7283f0502f0f026425617f494c52 @brianmario committed Jun 14, 2011
Showing with 3 additions and 83 deletions.
  1. +3 −83 benchmark/active_record.rb
View
86 benchmark/active_record.rb
@@ -22,83 +22,13 @@ class Mysql2Model < ActiveRecord::Base
set_table_name :mysql2_test
end
-class Mysql2Model2 < ActiveRecord::Base
- set_table_name :mysql2_test
-end
-
class MysqlModel < ActiveRecord::Base
set_table_name :mysql2_test
end
-Mysql2Model.establish_connection(mysql2_opts)
-
-Mysql2Model2.establish_connection(mysql2_opts)
-connection = Mysql2Model2.connection.instance_variable_get "@connection"
-connection.query_options[:cast_dates] = false
-connection.query_options[:cast_datetimes] = false
-
-Benchmark.bmbm do |x|
- x.report "Mysql2 (with auto casting, no attr access)" do
- number_of.times do
- Mysql2Model.all(:limit => 1000)
- end
- end
-
- x.report "Mysql2 (with lazy casting, no attr access)" do
- number_of.times do
- Mysql2Model2.all(:limit => 1000)
- end
- end
-
- x.report "Mysql (with lazy casting, no attr access)" do
- MysqlModel.establish_connection(mysql_opts)
- number_of.times do
- MysqlModel.all(:limit => 1000)
- end
- end
-end
-
-GC.start
-puts
-puts
-Benchmark.bmbm do |x|
- x.report "Mysql2 (with auto casting, read date/datetime/timestamp attrs)" do
- number_of.times do
- Mysql2Model.all(:limit => 1000).each{ |r|
- r.date_test
- r.date_time_test
- r.timestamp_test
- }
- end
- end
-
- x.report "Mysql2 (with lazy casting, read date/datetime/timestamp attrs)" do
- number_of.times do
- Mysql2Model2.all(:limit => 1000).each{ |r|
- r.date_test
- r.date_time_test
- r.timestamp_test
- }
- end
- end
-
- x.report "Mysql (with lazy casting, read date/datetime/timestamp attrs)" do
- MysqlModel.establish_connection(mysql_opts)
- number_of.times do
- MysqlModel.all(:limit => 1000).each{ |r|
- r.date_test
- r.date_time_test
- r.timestamp_test
- }
- end
- end
-end
-
-GC.start
-puts
-puts
Benchmark.bmbm do |x|
- x.report "Mysql2 (with auto casting, read all attrs)" do
+ x.report "Mysql2" do
+ Mysql2Model.establish_connection(mysql2_opts)
number_of.times do
Mysql2Model.all(:limit => 1000).each{ |r|
r.attributes.keys.each{ |k|
@@ -108,17 +38,7 @@ class MysqlModel < ActiveRecord::Base
end
end
- x.report "Mysql2 (with lazy casting, read all attrs)" do
- number_of.times do
- Mysql2Model2.all(:limit => 1000).each{ |r|
- r.attributes.keys.each{ |k|
- r.send(k.to_sym)
- }
- }
- end
- end
-
- x.report "Mysql (with lazy casting, read all attrs)" do
+ x.report "Mysql" do
MysqlModel.establish_connection(mysql_opts)
number_of.times do
MysqlModel.all(:limit => 1000).each{ |r|

0 comments on commit 90763ce

Please sign in to comment.
Something went wrong with that request. Please try again.