testing benchmark script

This commit is contained in:
Brian Lopez 2010-03-31 08:40:46 -07:00
parent 26619b10b6
commit ae5a028189
1 changed files with 29 additions and 23 deletions

View File

@ -1,42 +1,48 @@
# encoding: UTF-8 # encoding: UTF-8
require 'rubygems' require 'rubygems'
require 'benchmark' require 'memprof'
require 'mysql' # require 'benchmark'
# require 'mysql'
require 'mysql2_ext' require 'mysql2_ext'
number_of = 1 number_of = 1
database = 'nbb_1_production' database = 'nbb_1_production'
sql = "SELECT * FROM account_transactions" sql = "SELECT * FROM account_transactions"
Benchmark.bmbm do |x| # Benchmark.bmbm do |x|
mysql = Mysql.new("localhost", "root") Memprof.start
mysql.query "USE #{database}" # mysql = Mysql.new("localhost", "root")
x.report do # mysql.query "USE #{database}"
puts "Mysql" # x.report do
number_of.times do # puts "Mysql"
mysql_result = mysql.query sql # number_of.times do
# mysql_result = mysql.query sql
# number = 0 # number = 0
mysql_result.each_hash do |res| # mysql_result.each_hash do |res|
# number += 1 # number += 1
# puts res.inspect # puts res.inspect
end # end
# Memprof.stats
# Memprof.stop
# puts "Processed #{number} results" # puts "Processed #{number} results"
end # end
end # end
mysql2 = Mysql2::Client.new mysql2 = Mysql2::Client.new
mysql2.query "USE #{database}" mysql2.query "USE #{database}"
x.report do # x.report do
puts "Mysql2" # puts "Mysql2"
number_of.times do # number_of.times do
mysql2_result = mysql2.query sql mysql2_result = mysql2.query sql
# number = 0 # # number = 0
mysql2_result.each(:symbolize_keys => true) do |res| mysql2_result.each(:symbolize_keys => true) do |res|
# number += 1 # # number += 1
# puts res.inspect # # puts res.inspect
end end
# puts "Processed #{number} results" # # puts "Processed #{number} results"
end # end
end # end
end Memprof.stats
Memprof.stop
# end