Sha256: 3223a278e5a8763a1c0d33ecc8a359472556702c0fa6183e139df89a00f18073

Contents?: true

Size: 610 Bytes

Versions: 102

Compression:

Stored size: 610 Bytes

Contents

# encoding: utf-8

$LOAD_PATH.unshift 'lib'
require 'mysql2'
require 'timeout'

threads = []
# Should never exceed worst case 3.5 secs across all 20 threads
Timeout.timeout(3.5) do
  20.times do
    threads << Thread.new do
      overhead = rand(3)
      puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead"
      # 3 second overhead per query
      Mysql2::Client.new(:host => "localhost", :username => "root").query("SELECT sleep(#{overhead}) as result")
      puts "<< thread #{Thread.current.object_id} result, #{overhead} sec overhead"
    end
  end
  threads.each{|t| t.join }
end

Version data entries

102 entries across 99 versions & 10 rubygems

Version Path
mysql2-0.3.21-x86-mswin32-60 examples/threaded.rb
mysql2-0.3.21-x86-mingw32 examples/threaded.rb
mysql2-0.3.21-x64-mingw32 examples/threaded.rb
mysql2-0.3.21 examples/threaded.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/mysql2-0.3.20/examples/threaded.rb
mysql2-0.3.20-x86-mswin32-60 examples/threaded.rb
mysql2-0.3.20-x86-mingw32 examples/threaded.rb
mysql2-0.3.20-x64-mingw32 examples/threaded.rb
mysql2-0.3.20 examples/threaded.rb
mysql2-0.3.19-x86-mswin32-60 examples/threaded.rb
mysql2-0.3.19-x86-mingw32 examples/threaded.rb
mysql2-0.3.19-x64-mingw32 examples/threaded.rb
mysql2-0.3.19 examples/threaded.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/mysql2-0.3.18/examples/threaded.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/mysql2-0.3.18/examples/threaded.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/mysql2-0.3.18/examples/threaded.rb
mysql2-0.3.18-x64-mingw32 examples/threaded.rb
mysql2-0.3.18-x86-mswin32-60 examples/threaded.rb
mysql2-0.3.18-x86-mingw32 examples/threaded.rb
mysql2-0.3.18 examples/threaded.rb