Sha256: 1b0c03e6e95015fa5cdcfea2a6f25ca7604005d3a7d79bbd96250b2e1f28d918

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# encoding: UTF-8

require 'rubygems'
require 'benchmark'
require 'mysql'
require 'mysql2_ext'
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
      mysql2_result.each(:symbolize_keys => true) 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

4 entries across 4 versions & 1 rubygems

Version Path
mysql2-0.1.7 benchmark/query_without_mysql_casting.rb
mysql2-0.1.6 benchmark/query_without_mysql_casting.rb
mysql2-0.1.5 benchmark/query_without_mysql_casting.rb
mysql2-0.1.4 benchmark/query.rb