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