Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (18 sloc) 610 Bytes
# 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 << do
overhead = rand(3)
puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead"
# 3 second overhead per query => "localhost", :username => "root").query("SELECT sleep(#{overhead}) as result")
puts "<< thread #{Thread.current.object_id} result, #{overhead} sec overhead"
threads.each{|t| t.join }
Jump to Line
Something went wrong with that request. Please try again.