Sha256: d2f65efbcd5a281a7192e1c3834b7208b3e5567605f2d333cf2b0b86bc53e2bf

Contents?: true

Size: 502 Bytes

Versions: 120

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

require 'httparty'

URL = 'http://worldtimeapi.org/api/timezone/Europe/Paris'
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

120 entries across 120 versions & 1 rubygems

Version Path
polyphony-1.6 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.5 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.4 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.3 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.2.1 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.2 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.1.1 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.1 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.0.2 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.0.1 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-1.0 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.6 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.5 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.4 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.3 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.2 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99.1 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.99 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.98 examples/performance/thread-vs-fiber/httparty_threaded.rb
polyphony-0.97 examples/performance/thread-vs-fiber/httparty_threaded.rb