Skip to content

Instantly share code, notes, and snippets.

@gdiggs
Created September 16, 2013 20:22
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 gdiggs/6586064 to your computer and use it in GitHub Desktop.
Save gdiggs/6586064 to your computer and use it in GitHub Desktop.
Test response speed (somewhat poorly)
#!/usr/bin/env ruby
# Given a URL, hit it a bunch of times and record the time it takes
# please dont use this for DDOS
TRIALS = 100
url = ARGV[0]
if !url
puts "Bro, gotta have a url"
exit
end
puts "Hitting '#{url}' #{TRIALS} times..."
beginning_time = Time.now
TRIALS.times do
`curl -sIXGET #{url} > /dev/null`
end
end_time = Time.now
total_time = (end_time - beginning_time) * 1000
average_time = total_time / TRIALS
puts "#{TRIALS} requests took #{total_time} milliseconds"
puts "On average, a request took #{average_time} milliseconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment