Created
February 25, 2021 08:17
-
-
Save kinnalru/c84a253bd32e3bed4010f589986441fc to your computer and use it in GitHub Desktop.
make_requests_each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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