2009-04-18 22:39:12 +00:00
|
|
|
require 'mysqlplus'
|
2008-08-27 23:11:19 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'sequel'
|
|
|
|
|
|
|
|
class Mysql
|
|
|
|
unless method_defined? :sync_query
|
|
|
|
alias :sync_query :query
|
|
|
|
alias :query :async_query
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
DB = Sequel.connect('mysql://root@localhost', :max_connections => 20)
|
|
|
|
|
|
|
|
start = Time.now
|
|
|
|
|
|
|
|
(0..10).map do
|
|
|
|
Thread.new do
|
|
|
|
|
|
|
|
p DB['select sleep(2)'].all
|
|
|
|
|
|
|
|
end
|
|
|
|
end.map{|t| t.join }
|
|
|
|
|
2009-04-18 22:39:12 +00:00
|
|
|
p (Time.now - start)
|