mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
ef96cf1248
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@190 19e92222-5c0b-0410-8929-a290d50e31e9
37 lines
662 B
Ruby
37 lines
662 B
Ruby
require 'socket'
|
|
require 'stringio'
|
|
|
|
def do_test(st, chunk)
|
|
s = TCPSocket.new('127.0.0.1',ARGV[0].to_i);
|
|
req = StringIO.new(st)
|
|
|
|
while data = req.read(chunk)
|
|
puts "write #{data.length}: '#{data}'"
|
|
s.write(data)
|
|
s.flush
|
|
sleep 0.1
|
|
end
|
|
s.close
|
|
end
|
|
|
|
|
|
st = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
|
|
|
|
threads = []
|
|
ARGV[1].to_i.times do
|
|
threads << Thread.new do
|
|
(st.length - 1).times do |chunk|
|
|
puts ">>>> #{chunk+1} sized chunks"
|
|
do_test(st, chunk+1)
|
|
end
|
|
|
|
1000.times do
|
|
do_test(st, rand(st.length) + 1)
|
|
end
|
|
|
|
end
|
|
|
|
sleep(1+rand)
|
|
end
|
|
|
|
threads.each {|t| t.join}
|