Sha256: 73e0ef467ad8859c8710b3678d41573bd60b79eae00081d7150a87ad9eb6466b

Contents?: true

Size: 1.36 KB

Versions: 44

Compression:

Stored size: 1.36 KB

Contents

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

require 'rubygems'
require 'benchmark'
require 'mysql'
require 'mysql2'
require 'do_mysql'

number_of = 100
database = 'test'
sql = "SELECT * FROM mysql2_test LIMIT 100"

Benchmark.bmbm do |x|
  mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
  mysql2.query "USE #{database}"
  x.report "Mysql2 (cast: true)" do
    number_of.times do
      mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => true
      mysql2_result.each do |res|
        # puts res.inspect
      end
    end
  end

  x.report "Mysql2 (cast: false)" do
    number_of.times do
      mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => false
      mysql2_result.each do |res|
        # puts res.inspect
      end
    end
  end

  mysql = Mysql.new("localhost", "root")
  mysql.query "USE #{database}"
  x.report "Mysql" do
    number_of.times do
      mysql_result = mysql.query sql
      mysql_result.each_hash do |res|
        # puts res.inspect
      end
    end
  end

  do_mysql = DataObjects::Connection.new("mysql://localhost/#{database}")
  command = DataObjects::Mysql::Command.new do_mysql, sql
  x.report "do_mysql" do
    number_of.times do
      do_result = command.execute_reader
      do_result.each do |res|
        # puts res.inspect
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 4 rubygems

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