1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/tools/trickletest.rb

38 lines
662 B
Ruby
Raw Normal View History

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}