2010-04-01 19:04:55 +00:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
require 'rubygems'
|
|
|
|
require 'benchmark'
|
|
|
|
require 'mysql'
|
|
|
|
require 'mysql2_ext'
|
2010-04-03 23:47:25 +00:00
|
|
|
require 'do_mysql'
|
2010-04-01 19:04:55 +00:00
|
|
|
|
|
|
|
number_of = 1000
|
|
|
|
str = "abc'def\"ghi\0jkl%mno"
|
|
|
|
|
|
|
|
Benchmark.bmbm do |x|
|
|
|
|
mysql = Mysql.new("localhost", "root")
|
|
|
|
x.report do
|
|
|
|
puts "Mysql"
|
|
|
|
number_of.times do
|
2010-04-03 23:47:25 +00:00
|
|
|
mysql.quote str
|
2010-04-01 19:04:55 +00:00
|
|
|
end
|
|
|
|
end
|
2010-04-03 08:35:41 +00:00
|
|
|
|
|
|
|
mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
|
2010-04-01 19:04:55 +00:00
|
|
|
x.report do
|
|
|
|
puts "Mysql2"
|
|
|
|
number_of.times do
|
|
|
|
mysql2.escape str
|
|
|
|
end
|
|
|
|
end
|
2010-04-03 23:47:25 +00:00
|
|
|
|
2010-04-15 17:53:58 +00:00
|
|
|
do_mysql = DataObjects::Connection.new("mysql://localhost/test")
|
2010-04-03 23:47:25 +00:00
|
|
|
x.report do
|
|
|
|
puts "do_mysql"
|
|
|
|
number_of.times do
|
|
|
|
do_mysql.quote_string str
|
|
|
|
end
|
|
|
|
end
|
2010-04-01 19:04:55 +00:00
|
|
|
end
|