Created
November 16, 2011 08:19
-
-
Save yura/1369564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Тест из видео Ильи Григорика http://www.igvita.com/2010/06/07/rails-performance-needs-an-overhaul/ | |
require 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => :mysql, | |
:database => 'mysql', | |
:username => 'root', | |
:password => '', | |
:pool => 5 | |
) | |
threads = [] | |
10.times do |n| | |
threads << Thread.new { | |
ActiveRecord::Base.connection_pool.with_connection do |conn| | |
res = conn.execute('select sleep(1)') | |
end | |
} | |
end | |
threads.each { |t| t.join } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment