add escape benchmark
This commit is contained in:
parent
953f547f79
commit
d1466a10f1
|
@ -0,0 +1,30 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require 'rubygems'
|
||||
require 'benchmark'
|
||||
require 'mysql'
|
||||
require 'mysql2_ext'
|
||||
|
||||
number_of = 1000
|
||||
database = 'nbb_1_production'
|
||||
str = "abc'def\"ghi\0jkl%mno"
|
||||
|
||||
Benchmark.bmbm do |x|
|
||||
mysql = Mysql.new("localhost", "root")
|
||||
mysql.query "USE #{database}"
|
||||
x.report do
|
||||
puts "Mysql"
|
||||
number_of.times do
|
||||
mysql.escape_string str
|
||||
end
|
||||
end
|
||||
GC.start
|
||||
mysql2 = Mysql2::Client.new
|
||||
mysql2.query "USE #{database}"
|
||||
x.report do
|
||||
puts "Mysql2"
|
||||
number_of.times do
|
||||
mysql2.escape str
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue