Sha256: 7539172b5b8f670252cb695b0218b0b44dcf1ca4d8365e81e086187d2606e6ca

Contents?: true

Size: 918 Bytes

Versions: 295

Compression:

Stored size: 918 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

295 entries across 290 versions & 29 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/tools/trickletest.rb