Skip to content

Instantly share code, notes, and snippets.

@kinnalru
Created February 25, 2021 08:17
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 kinnalru/c84a253bd32e3bed4010f589986441fc to your computer and use it in GitHub Desktop.
Save kinnalru/c84a253bd32e3bed4010f589986441fc to your computer and use it in GitHub Desktop.
make_requests_each
def make_requests_each(uri, duration)
count = 0
t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
while (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t) < duration do
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.max_retries = 0
data = "/#{count}"
http.get(uri + data).body
count += 1
end
end
count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment