Skip to content

Instantly share code, notes, and snippets.

@cyfdecyf
Created July 22, 2011 12:07
Show Gist options
  • Save cyfdecyf/1099316 to your computer and use it in GitHub Desktop.
Save cyfdecyf/1099316 to your computer and use it in GitHub Desktop.
Find fast app store download servers
#!/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