Sha256: d3fc8eee655aa54e6d17863d367c844027080f6e0639784440ad650c3fa49938

Contents?: true

Size: 1.02 KB

Versions: 50

Compression:

Stored size: 1.02 KB

Contents

# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'
require 'active_record'

ActiveRecord::Base.default_timezone = :local
ActiveRecord::Base.time_zone_aware_attributes = true

number_of = 10
mysql2_opts = {
  :adapter => 'mysql2',
  :database => 'test'
}
mysql_opts = {
  :adapter => 'mysql',
  :database => 'test'
}

class Mysql2Model < ActiveRecord::Base
  set_table_name :mysql2_test
end

class MysqlModel < ActiveRecord::Base
  set_table_name :mysql2_test
end

Benchmark.bmbm do |x|
  x.report "Mysql2" do
    Mysql2Model.establish_connection(mysql2_opts)
    number_of.times do
      Mysql2Model.all(:limit => 1000).each{ |r|
        r.attributes.keys.each{ |k|
          r.send(k.to_sym)
        }
      }
    end
  end

  x.report "Mysql" do
    MysqlModel.establish_connection(mysql_opts)
    number_of.times do
      MysqlModel.all(:limit => 1000).each{ |r|
        r.attributes.keys.each{ |k|
          r.send(k.to_sym)
        }
      }
    end
  end
end

Version data entries

50 entries across 50 versions & 6 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
mysql2-0.2.19b4 benchmark/active_record.rb
mysql2-0.3.12b4 benchmark/active_record.rb
mysql2-0.2.19b3 benchmark/active_record.rb
mysql2-0.3.12b3 benchmark/active_record.rb
mysql2-0.3.12b2 benchmark/active_record.rb
mysql2-0.2.19b2 benchmark/active_record.rb
mysql2-0.3.12b1 benchmark/active_record.rb
mysql2-0.2.19b1 benchmark/active_record.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/active_record.rb
mysql2-sp-0.3.10 benchmark/active_record.rb
solaris-mysql2-0.3.11 benchmark/active_record.rb
mysql2-0.3.11-x86-mswin32-60 benchmark/active_record.rb
mysql2-0.3.11-x86-mingw32 benchmark/active_record.rb
mysql2-0.3.11 benchmark/active_record.rb
mysql2-0.2.18-x86-mswin32-60 benchmark/active_record.rb