Sha256: fe15bc7275b65f6f8bceac1b626032807f010f8e8ea1852872b238ad4d6a3a51

Contents?: true

Size: 482 Bytes

Versions: 4

Compression:

Stored size: 482 Bytes

Contents

# frozen_string_literal: true

require 'httparty'

url = 'http://127.0.0.1:4411/?q=time'
results = Queue.new

t0 = Time.now
threads = []
10.times do
  threads << Thread.new do
    loop do
      STDOUT << '!'
      if (result = HTTParty.get(url))
        results << result
        STDOUT << '.'
      end
    end
  end
end

sleep 3
threads.each(&:kill)
puts 'done'
puts format(
  'got %<count>d (%<rate>0.1f reqs/s)',
  count: results.size,
  rate:  results.size / (Time.now - t0)
)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polyphony-0.23 examples/io/httparty_threaded.rb
polyphony-0.22 examples/io/httparty_threaded.rb
polyphony-0.21 examples/io/httparty_threaded.rb
polyphony-0.20 examples/io/httparty_threaded.rb