Sha256: bab6e15555468b7f702d6fa2529a15f4c45390f37105e3a67ef1c92d578bad6c

Contents?: true

Size: 917 Bytes

Versions: 37

Compression:

Stored size: 917 Bytes

Contents

require 'socket'
require 'stringio'

def do_test(st, chunk)
  s = TCPSocket.new('127.0.0.1',ARGV[0].to_i);
  req = StringIO.new(st)
  nout = 0
  randstop = rand(st.length / 10)
  STDERR.puts "stopping after: #{randstop}"

  begin
    while data = req.read(chunk)
      nout += s.write(data)
      s.flush
      sleep 0.1
      if nout > randstop
        STDERR.puts "BANG! after #{nout} bytes."
        break
      end
    end
  rescue Object => e
    STDERR.puts "ERROR: #{e}"
  ensure
    s.close
  end
end

content = "-" * (1024 * 240)
st = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\nContent-Length: #{content.length}\r\n\r\n#{content}"

puts "length: #{content.length}"

threads = []
ARGV[1].to_i.times do
  t = Thread.new do
    size = 100
    puts ">>>> #{size} sized chunks"
    do_test(st, size)
  end

  t.abort_on_exception = true
  threads << t
end

threads.each {|t|  t.join}

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
piesync-puma-3.12.6.1 tools/trickletest.rb
piesync-puma-3.12.6 tools/trickletest.rb
puma-3.12.6-java tools/trickletest.rb
puma-3.12.6 tools/trickletest.rb
puma-3.12.5-java tools/trickletest.rb
puma-3.12.5 tools/trickletest.rb
puma-3.12.4-java tools/trickletest.rb
puma-3.12.4 tools/trickletest.rb
puma-3.12.2-java tools/trickletest.rb
puma-3.12.2 tools/trickletest.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/tools/trickletest.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/tools/trickletest.rb
puma-4.1.1-java tools/trickletest.rb
puma-4.1.1 tools/trickletest.rb
puma-4.1.0-java tools/trickletest.rb
puma-4.1.0 tools/trickletest.rb
puma-4.0.1-java tools/trickletest.rb
puma-4.0.1 tools/trickletest.rb
puma-4.0.0-java tools/trickletest.rb
puma-4.0.0 tools/trickletest.rb