Sha256: 4ab542ed96952aecb3caee4f58ea427367569a7b508dda0408bf8123fa589b8f

Contents?: true

Size: 552 Bytes

Versions: 12

Compression:

Stored size: 552 Bytes

Contents

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

# Should never exceed worst case 3.5 secs across all 20 threads
Timeout.timeout(3.5) do
  Array.new(20) do
    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.each(&:join)
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mysql2-0.5.2-x64-mingw32 examples/threaded.rb
mysql2-0.5.2-x86-mingw32 examples/threaded.rb
mysql2-0.5.2-x86-mswin32-60 examples/threaded.rb
mysql2-0.5.2 examples/threaded.rb
mysql2-0.5.1-x64-mingw32 examples/threaded.rb
mysql2-0.5.1-x86-mingw32 examples/threaded.rb
mysql2-0.5.1-x86-mswin32-60 examples/threaded.rb
mysql2-0.5.1 examples/threaded.rb
mysql2-0.5.0-x64-mingw32 examples/threaded.rb
mysql2-0.5.0-x86-mingw32 examples/threaded.rb
mysql2-0.5.0-x86-mswin32-60 examples/threaded.rb
mysql2-0.5.0 examples/threaded.rb