Created
September 16, 2013 20:22
-
-
Save gdiggs/6586064 to your computer and use it in GitHub Desktop.
Test response speed (somewhat poorly)
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
#!/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