Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Created February 24, 2023 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob-murray/d3a1bc4c080e3be15c50469df0594329 to your computer and use it in GitHub Desktop.
Save rob-murray/d3a1bc4c080e3be15c50469df0594329 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'benchmark'
def make_request(sleep_mins, read_timeout = 1)
puts "sleep_mins=#{sleep_mins} mins read_timeout=#{read_timeout} mins"
uri = URI.parse 'http://localhost:4040'
request = Net::HTTP::Get.new("/sleep?m=#{sleep_mins}")
Net::HTTP.start(uri.host, uri.port, read_timeout: (read_timeout * 60)) do |http|
http.request(request)
end
end
puts Benchmark.realtime { make_request(0.5) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment