Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trilogy is much slower than mysql2 to connect to an IP #129

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions contrib/ruby/script/benchmark-connect
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env ruby

require "rubygems" if !defined?(Gem)
require "bundler/setup"

require "benchmark/ips"
require "trilogy"
require "mysql2"

DEFAULT_USER = ENV["MYSQL_USER"] || "root"
DEFAULT_PASS = ENV["MYSQL_PASS"]

connect_options = {
username: DEFAULT_USER,
password: DEFAULT_PASS,
host: "127.0.0.1",
}

client = Trilogy.new(connect_options)
p client.query("SELECT 1")
client = Mysql2::Client.new(connect_options)
p client.query("SELECT 1")

puts "=== Connecting to 'localhost'. "
Benchmark.ips do |x|
x.report "trilogy connect/close" do
client = Trilogy.new(connect_options)
client.query("SELECT 1")
client.close
end

x.report "mysql2 connect/close" do
client = Mysql2::Client.new(connect_options)
client.query("SELECT 1")
client.close
end

x.compare!
end
Loading