Sha256: 36a95835b5557176c18bb05971a8dd7e34caf28a2d59396ed7ad76100ff7d580

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 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 do
    puts "Mysql2"
    number_of.times do
      mysql2_result = mysql2.query sql, :symbolize_keys => true
      mysql2_result.each do |res|
        # puts res.inspect
      end
    end
  end

  mysql = Mysql.new("localhost", "root")
  mysql.query "USE #{database}"
  x.report do
    puts "Mysql"
    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
    puts "do_mysql"
    number_of.times do
      do_result = command.execute_reader
      do_result.each do |res|
        # puts res.inspect
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ghazel-mysql2-0.2.6.3 benchmark/query_without_mysql_casting.rb
ghazel-mysql2-0.2.6.2 benchmark/query_without_mysql_casting.rb
ghazel-mysql2-0.2.6.1 benchmark/query_without_mysql_casting.rb
mysql2-0.2.6 benchmark/query_without_mysql_casting.rb
mysql2-0.2.6-x86-mswin32-60 benchmark/query_without_mysql_casting.rb
mysql2-0.2.6-x86-mingw32 benchmark/query_without_mysql_casting.rb
mysql2-0.2.5 benchmark/query_without_mysql_casting.rb
mysql2-0.2.4 benchmark/query_without_mysql_casting.rb
mysql2-0.2.3 benchmark/query_without_mysql_casting.rb
mysql2-0.2.2 benchmark/query_without_mysql_casting.rb
mysql2-0.2.1 benchmark/query_without_mysql_casting.rb
mysql2-0.2.0 benchmark/query_without_mysql_casting.rb