Sha256: c164467e7cf695a049ad85af7ff5ef00c4b12fbca236398595585d0581bfe237

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

# encoding: UTF-8

require 'rubygems'
require 'benchmark'
require 'mysql'
require 'mysql2_ext'
require 'do_mysql'

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.quote str
    end
  end

  mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
  mysql2.query "USE #{database}"
  x.report do
    puts "Mysql2"
    number_of.times do
      mysql2.escape str
    end
  end

  do_mysql = DataObjects::Connection.new("mysql://localhost/#{database}")
  x.report do
    puts "do_mysql"
    number_of.times do
      do_mysql.quote_string str
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mysql2-0.1.2 benchmark/escape.rb
mysql2-0.1.1 benchmark/escape.rb
mysql2-0.1.0 benchmark/escape.rb