2010-03-30 17:18:29 +00:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
require 'rubygems'
|
|
|
|
require 'benchmark'
|
|
|
|
require 'mysql'
|
|
|
|
require 'mysql2_ext'
|
|
|
|
|
2010-03-30 23:40:41 +00:00
|
|
|
number_of = 1
|
|
|
|
database = 'nbb_1_production'
|
2010-03-30 17:18:29 +00:00
|
|
|
|
|
|
|
Benchmark.bmbm do |x|
|
|
|
|
GC.start
|
|
|
|
mysql = Mysql.new("localhost", "root")
|
2010-03-30 23:40:41 +00:00
|
|
|
mysql.query "USE #{database}"
|
2010-03-30 17:18:29 +00:00
|
|
|
x.report do
|
|
|
|
puts "Mysql"
|
|
|
|
number_of.times do
|
|
|
|
mysql_result = mysql.query "SELECT * FROM account_transactions"
|
2010-03-30 23:40:41 +00:00
|
|
|
number = 0
|
|
|
|
mysql_result.each_hash do |res|
|
|
|
|
number += 1
|
|
|
|
# puts res.inspect
|
|
|
|
end
|
|
|
|
puts "Processed #{number} results"
|
2010-03-30 17:18:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
GC.start
|
|
|
|
mysql2 = Mysql2::Client.new
|
2010-03-30 23:40:41 +00:00
|
|
|
mysql2.query "USE #{database}"
|
2010-03-30 17:18:29 +00:00
|
|
|
x.report do
|
|
|
|
puts "Mysql2"
|
|
|
|
number_of.times do
|
|
|
|
mysql2_result = mysql2.query "SELECT * FROM account_transactions"
|
2010-03-30 23:40:41 +00:00
|
|
|
number = 0
|
|
|
|
mysql2_result.each(:symbolize_keys => true) do |res|
|
|
|
|
number += 1
|
|
|
|
# puts res.inspect
|
|
|
|
end
|
|
|
|
puts "Processed #{number} results"
|
2010-03-30 17:18:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|