mysql2/benchmark/query.rb

48 lines
1.0 KiB
Ruby
Raw Normal View History

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