Sha256: 5994c772337c42e2202063e091c0c28d276248f91df150b8aea078d9fc5c99d9

Contents?: true

Size: 576 Bytes

Versions: 45

Compression:

Stored size: 576 Bytes

Contents

# encoding: utf-8

$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
  20.times.map 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

45 entries across 45 versions & 2 rubygems

Version Path
mysql2-0.4.10-x86-mswin32-60 examples/threaded.rb
mysql2-0.4.10-x86-mingw32 examples/threaded.rb
mysql2-0.4.10-x64-mingw32 examples/threaded.rb
mysql2-0.4.10 examples/threaded.rb
mysql2-0.4.9-x86-mswin32-60 examples/threaded.rb
mysql2-0.4.9-x86-mingw32 examples/threaded.rb
mysql2-0.4.9-x64-mingw32 examples/threaded.rb
mysql2-0.4.9 examples/threaded.rb
mysql2-0.4.8-x86-mswin32-60 examples/threaded.rb
mysql2-0.4.8-x86-mingw32 examples/threaded.rb
mysql2-0.4.8-x64-mingw32 examples/threaded.rb
mysql2-0.4.8 examples/threaded.rb
mysql2-0.4.7-x86-mswin32-60 examples/threaded.rb
mysql2-0.4.7-x86-mingw32 examples/threaded.rb
mysql2-0.4.7-x64-mingw32 examples/threaded.rb
mysql2-0.4.7 examples/threaded.rb
mysql2-0.4.6-x86-mswin32-60 examples/threaded.rb
mysql2-0.4.6-x86-mingw32 examples/threaded.rb
mysql2-0.4.6-x64-mingw32 examples/threaded.rb
mysql2-0.4.6 examples/threaded.rb