Created
July 22, 2011 12:07
-
-
Save cyfdecyf/1099316 to your computer and use it in GitHub Desktop.
Find fast app store download servers
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 | |
# Run the following commands to find the fastest server. | |
# | |
# ./appstore-avgtime.rb > speed | |
# sort -n speed | head -n 10 | |
STDOUT.sync = true | |
def pingavg(url, count = 10) | |
cmd = "ping -c #{count} #{url}" | |
$stderr.puts cmd | |
lastline = `#{cmd}`.to_a[-1] | |
lastline.split('/')[4].to_f | |
end | |
2000.times do |i| | |
url = "a#{i+1}.phobos.apple.com" | |
avg = pingavg url, 4 | |
puts "#{avg}\t#{url}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment