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-0.43.2 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.43.1 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.43 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.42 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.41 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.40 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.39 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.38 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.36 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.34 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.33 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.32 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.31 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.30 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.29 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.28 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.27 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.26 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.25 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
polyphony-0.24 examples/performance/thread-vs-fiber/xx-httparty_threaded.rb