Skip to content

Instantly share code, notes, and snippets.

@eduardopoleo
Created August 10, 2019 20:01
Show Gist options
  • Save eduardopoleo/58844e2d3b29fe73a4ac7e8111d0ea62 to your computer and use it in GitHub Desktop.
Save eduardopoleo/58844e2d3b29fe73a4ac7e8111d0ea62 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
url = ARGV[0]
uri = URI(url)
users = ARGV[1].to_i
$requests = 0
$errors = 0
initial_time = Time.now
for i in 0..users
Thread.new do
begin
while true
response = Net::HTTP.get_response(uri) # => String
$requests += 1
end
rescue StandardError => e
$errors += 1
error_pct = ($errors / $requests.to_f) * 100
time_elapsed = ((Time.now - initial_time) / 60).round(2)
p "Error(%): #{error_pct}. Total Time: #{time_elapsed} mins"
retry
end
end
end
sleep(300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment