Skip to content

Instantly share code, notes, and snippets.

@kinnalru
Created February 25, 2021 08:20
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/6dada253de9d2e76a1f105c56b8465d9 to your computer and use it in GitHub Desktop.
Save kinnalru/6dada253de9d2e76a1f105c56b8465d9 to your computer and use it in GitHub Desktop.
make_requests_single
def make_requests_single(uri, duration)
count = 0
t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.max_retries = 0
while (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t) < duration do
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