This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/mysql2/benchmarks/ruby-mysql2/bench.rb

30 lines
721 B
Ruby
Raw Normal View History

2014-09-24 17:56:53 -04:00
require 'rubygems'
require 'benchmark'
require 'mysql2'
require 'haml'
number_of = 1
database = 'test'
sql = "SELECT * FROM mysql2_test LIMIT 1"
Benchmark.bmbm do |x|
mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
mysql2.query "USE #{database}"
x.report "Mysql2 (cast: true)" do
number_of.times do
mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => true
puts haml :index, :locals => { :rows => mysqql2_result }
end
end
x.report "Mysql2 (cast: false)" do
number_of.times do
mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => false
mysql2_result.each do |res|
# puts res.inspect
end
end
end
end