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
zedshaw ef96cf1248 Initial code review fixing some things, and rcov addition.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@190 19e92222-5c0b-0410-8929-a290d50e31e9
2006-05-20 02:56:30 +00:00

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}