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